Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

countonce

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

countonce

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CountOnce-ruby

Wrapper for the CountOnce API

Installation

Add this line to your application's Gemfile:

gem 'countonce'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install countonce

Usage

Ping

require "countonce"

co_client = CountOnce.new({
  account_id: "<account_id>",
  auth_token: "<your api auth token>"
})

begin

  response = co_client.ping({
    key: "<key>",
    attributes: {
      account_id: "<attribute value>",
      action: "<attribute value>"
    },
    unique_value: "<unique id or hash>",
    revenue: 0.00
  })
  puts response.json

rescue StandardError => e
  puts e.message

end

The '.then' function only works on Windows for now. Hence, the following example is Windows only.

require "countonce"

co_client = CountOnce.new({
  account_id: "<account_id>",
  auth_token: "<your api auth token>"
})

begin

  co_client.async.ping({
    key: "<key>",
    attributes: {
      account_id: "<attribute value>",
      action: "<attribute value>"
    },
    unique_value: "<unique id or hash>",
    revenue: 0.00
  }).then {|response| puts response.value.json}

rescue StandardError => e
  puts e.message

end

Query

require "countonce"

co_client = CountOnce.new({
  account_id: "<account_id>", 
  auth_token: "<your api auth token>"
})

query_options = {
  metric: "daily"
}

begin

  data = co_client.getUniques("<key>", query_options)
  p data.json

rescue StandardError => e
  puts e.message

end

Same case as for the ping example. You can use the then function but only with Windows.

require "countonce"

co_client = CountOnce.new({
  account_id: "<account_id>", 
  auth_token: "<your api auth token>"
})

query_options = {
  metric: "daily"
}

begin

  co_client.async.getUniques("<key>", query_options).then {|data|
    p data.value.json
  }

rescue StandardError => e
  puts e.message

end

For more information on async, please refer to the concurrent-ruby's documentation.

FAQs

Package last updated on 20 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc