Project

countonce

0.0
No commit activity in last 3 years
No release in over 3 years
Wrapper for the CountOnce API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.18.0
 Project Readme

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.