This gem is a wrapper for the Kayzen REST Api. Kayzen is a bidder for mobile advertising.
Add the gem to your Gemfile with:
gem 'kayzen_api', git: "https://github.com/LatanaTech/kayzen_api"
and then run bundle install
.
The gem must be configured with the following options (we recommend adding this to an initializer in your application):
KayzenApi::App.configure do |config|
config.api_key = "api-key"
config.secret_api_key = "secret-api-key"
config.username = "username"
config.password = "password"
end
Optionally, you can also pass a custom logger like this (by default the gem will not generate logs):
KayzenApi::App.configure do |config|
config.logger = Rails.logger # Could also use Logger.new(STDOUT)
end
The Kayzen API has an authentication/token
endpoint which issues an Oauth token that expires after 30 minutes. This gem ensures that there is always a valid Oauth token present before making a request (and requests that token if not).
Your application code does not need to explicitly make an authentication request - the gem will do this if one is neccessary.
# Makes a request to https://api.kayzen.io/v1/campaigns
KayzenApi::Campaign.get
# The gem returns a Response object, where the body attribute contains the body of the API response from Kayzen
# <KayzenApi::Response success=true code=200 body=[]>
# If you need to pass params to the request, you can do so like this
KayzenApi::Campaign.get(params: {q: "Demo"})
# The gem supports some shorthands for making requests, like following:
KayzenApi::Campaign.get(id: "866803")
# You can also set headers for the request
KayzenApi::Campaign.get(headers: {"Accept" => "application/json"})
# Some endpoints are implemented as nested resources, like this
KayzenApi::Campaign::Detail.get(id: "866803")
# Make a request with custom path and params
KayzenApi::Report.get(path: "866803/report_results", params: {start_date: "2024-
02-01", end_date: "2024-02-19"})
# Make a request for creating an entity (POST)
KayzenApi::CreativesBulk.create(body: {creatives: [params]})
- Clone this repo
- Ensure you have the ruby-version defined in
.ruby-version
bundle install
to install all the gemscp .env .env.development
then add your Kayzen credentials to.env.development
- Open an IRB console with the gem loaded:
irb -I lib -r ./lib/kayzen_api.rb
- Run the script at
development_setup_script.rb
to configure the gem with your credentials from the.env.development
file
For linting, run standardrb --fix
Bug reports and pull requests are welcome on GitHub at https://github.com/LatanaTech/kayzen_api.
The gem is available as open source under the terms of the MIT License.