adtraction-api 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44351005560cd321ae257c4c827faede38685b4edc723a4a0d30f9389f478012
4
- data.tar.gz: 194329ea1b9319cd3bdeeff05548cf8a0211b0bd142d40e3773aeea91c9c6c75
3
+ metadata.gz: ccdc5f5c644b82a99b16cb8274474b49e46a4d8c608e6ab7fb96366336d74509
4
+ data.tar.gz: a69e42f6d2652d002f3947ef8649174d501d2b4f9a3f65f67718a15927de1475
5
5
  SHA512:
6
- metadata.gz: 8a9e416e3af3dd4252732943ca676709d61f44f6bf42a92364363054c4a9f263c63b8928bb2086841da46dd640ce032675891fdff256549c46455696b77895d7
7
- data.tar.gz: 33b0178996f9a83a3a39c20679a829a69b81bb42fb931205096f4f0d2e7ef1ef49627de2147656acb2585960a8149316033842c0645e00e5b79e2f42152e1aa1
6
+ metadata.gz: 3c996e20165389fe5070efd55b61dafdd91eaf9d6df90613bf03b3acf6ebf2c034879b35e8743a8d90454c5db2728d9a1d28a8e52fa9759adc406e4d8ad56295
7
+ data.tar.gz: ab3a9e8cb4372c0eb3176ec8f21e573f62c5eafd3d038fcbd968c1944516a58f77b9c992e0df23ec6f3f17682807678957aedc795e1a5b2d2997843805b8b6d2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adtraction-api (0.1.0)
4
+ adtraction-api (0.1.2)
5
5
  faraday (>= 0.15.4)
6
6
  faraday_middleware (>= 0.13.1)
7
7
  virtus (>= 1.0.5)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Adtraction::API
1
+ # Adtraction::Api
2
2
 
3
- Adtraction::API is a Ruby client to interact with [Adtraction's](https://adtraction.com) [API](https://adtraction.docs.apiary.io/#).
3
+ Adtraction::Api is a Ruby client to interact with [Adtraction's](https://adtraction.com) [API](https://adtraction.docs.apiary.io/#).
4
4
 
5
5
  ## Installation
6
6
 
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
  First of all you need an Adtraction account in order to get your API key. After you've gotten ahold of your API key, configure the client to use it:
24
24
 
25
25
  ```ruby
26
- Adtraction::API.configure do |config|
26
+ Adtraction::Api.configure do |config|
27
27
  config.api_key = "YOUR_API_KEY"
28
28
  end
29
29
  ```
@@ -37,7 +37,14 @@ rails g adtraction:api:install Adtraction
37
37
  If you're trying to access the API using multiple API keys, then initialize each client with its own separate config:
38
38
 
39
39
  ```ruby
40
- Adtraction::API::Client.new(configuration: Adtraction::API::Configuration.new(api_key: "SOME_OTHER_API_KEY"))
40
+ Adtraction::Api::Client.new(configuration: Adtraction::Api::Configuration.new(api_key: "SOME_OTHER_API_KEY"))
41
+ ```
42
+
43
+ To instantiate a client, simply:
44
+
45
+ ```ruby
46
+ client = Adtraction::Api::Client.new
47
+ client.approved_channels
41
48
  ```
42
49
 
43
50
  This project is a WIP and not all endpoints have been implemented. They'll be gradually implemented depending on what I personally need to use from the API.
@@ -64,4 +71,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
64
71
 
65
72
  ## Code of Conduct
66
73
 
67
- Everyone interacting in the Adtraction::API project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/adtraction-api/blob/master/CODE_OF_CONDUCT.md).
74
+ Everyone interacting in the Adtraction::Api project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/adtraction-api/blob/master/CODE_OF_CONDUCT.md).
@@ -5,7 +5,7 @@ require "adtraction/api/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "adtraction-api"
8
- spec.version = Adtraction::API::VERSION
8
+ spec.version = Adtraction::Api::VERSION
9
9
  spec.authors = ["Sebastian Johnsson"]
10
10
  spec.email = ["sebastian.johnsson@gmail.com"]
11
11
 
data/bin/console CHANGED
@@ -9,11 +9,11 @@ cfg_path = File.join(File.dirname(__FILE__), "../credentials.yml"
9
9
  if ::File.exists?(cfg_path)
10
10
  cfg = YAML.load_file(cfg_path)
11
11
 
12
- Adtraction::API.configure do |config|
12
+ Adtraction::Api.configure do |config|
13
13
  config.api_key = cfg["api_key"]
14
14
 
15
15
  config.faraday = {
16
- user_agent: "Adtraction Ruby Client #{::Adtraction::API::VERSION}",
16
+ user_agent: "Adtraction Ruby Client #{::Adtraction::Api::VERSION}",
17
17
  verbose: true
18
18
  }
19
19
  end
@@ -19,18 +19,18 @@ if !String.instance_methods(false).include?(:camelize)
19
19
  end
20
20
 
21
21
  module Adtraction
22
- module API
22
+ module Api
23
23
 
24
24
  class << self
25
25
  attr_writer :configuration
26
26
  end
27
27
 
28
28
  def self.configuration
29
- @configuration ||= ::Adtraction::API::Configuration.new
29
+ @configuration ||= ::Adtraction::Api::Configuration.new
30
30
  end
31
31
 
32
32
  def self.reset
33
- @configuration = ::Adtraction::API::Configuration.new
33
+ @configuration = ::Adtraction::Api::Configuration.new
34
34
  end
35
35
 
36
36
  def self.configure
@@ -1,10 +1,10 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  module Affiliate
4
4
  module Channels
5
5
 
6
6
  def approved_channels(path: "/affiliate/approvedchannels", options: {})
7
- ::Adtraction::API::Models::Channel.parse(get(path, options: options)&.body)
7
+ ::Adtraction::Api::Models::Channel.parse(get(path, options: options)&.body)
8
8
  end
9
9
 
10
10
  end
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  module Affiliate
4
4
  module Programs
5
5
 
@@ -12,7 +12,7 @@ module Adtraction
12
12
  data[param.to_s.camelize(:lower)] = value unless value.nil?
13
13
  end
14
14
 
15
- ::Adtraction::API::Models::Program.parse(post(path, data: data, options: options)&.body)
15
+ ::Adtraction::Api::Models::Program.parse(post(path, data: data, options: options)&.body)
16
16
  end
17
17
 
18
18
  def program_info(program_id, path: "/affiliate/programinfo", options: {})
@@ -1,15 +1,15 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  class Client
4
4
  attr_accessor :configuration
5
5
 
6
- def initialize(configuration: ::Adtraction::API.configuration)
6
+ def initialize(configuration: ::Adtraction::Api.configuration)
7
7
  self.configuration = configuration
8
8
  raise InvalidApiKeyError, "You need to supply a valid API key!" if self.configuration.api_key.to_s.empty?
9
9
  end
10
10
 
11
- include Adtraction::API::Affiliate::Channels
12
- include Adtraction::API::Affiliate::Programs
11
+ include Adtraction::Api::Affiliate::Channels
12
+ include Adtraction::Api::Affiliate::Programs
13
13
 
14
14
  def to_uri(path)
15
15
  path = path.gsub(/^\//i, "")
@@ -35,7 +35,7 @@ module Adtraction
35
35
  def request(path, method: :get, params: {}, data: {}, headers: {}, options: {})
36
36
  headers = {
37
37
  "X-Token" => self.configuration.api_key,
38
- "User-Agent" => self.configuration.faraday.fetch(:user_agent, "Adtraction Ruby Client #{::Adtraction::API::VERSION}"),
38
+ "User-Agent" => self.configuration.faraday.fetch(:user_agent, "Adtraction Ruby Client #{::Adtraction::Api::VERSION}"),
39
39
  "Content-Type" => "application/json"
40
40
  }.merge(headers)
41
41
 
@@ -68,7 +68,7 @@ module Adtraction
68
68
  end
69
69
 
70
70
  def log(message)
71
- puts "[Adtraction::API::Client] - #{Time.now}: #{message}" if !message.to_s.empty? && self.verbose
71
+ puts "[Adtraction::Api::Client] - #{Time.now}: #{message}" if !message.to_s.empty? && self.verbose
72
72
  end
73
73
 
74
74
  end
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  class Configuration
4
4
  attr_accessor :host, :api_version, :api_key, :faraday
5
5
 
@@ -10,7 +10,7 @@ module Adtraction
10
10
 
11
11
  self.faraday = {
12
12
  adapter: :net_http,
13
- user_agent: "Adtraction Ruby Client #{::Adtraction::API::VERSION}",
13
+ user_agent: "Adtraction Ruby Client #{::Adtraction::Api::VERSION}",
14
14
  verbose: false
15
15
  }
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  module Constants
4
4
 
5
5
  TRANSACTION_TYPE_ENUM = {
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  module Models
4
4
 
5
5
  class Channel
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
2
+ module Api
3
3
  module Models
4
4
 
5
5
  class Program
@@ -59,15 +59,15 @@ module Adtraction
59
59
  program.send("#{column}=", item.fetch(api_column, nil))
60
60
  end
61
61
 
62
- program.approval_status = Adtraction::API::Constants::APPROVAL_STATUS_ENUM.fetch(item.fetch("approvalStatus"))
63
- program.email_marketing = Adtraction::API::Constants::EMAIL_MARKETING_ENUM.fetch(item.fetch("emailMarketing"))
64
- program.sem_marketing = Adtraction::API::Constants::SEM_MARKETING_ENUM.fetch(item.fetch("semMarketing"))
65
- program.social_marketing = Adtraction::API::Constants::SOCIAL_MARKETING_ENUM.fetch(item.fetch("socialMarketing"))
66
- program.cashback_marketing = Adtraction::API::Constants::CASHBACK_MARKETING_ENUM.fetch(item.fetch("cashbackMarketing"))
67
- program.coupon_marketing = Adtraction::API::Constants::COUPON_MARKETING_ENUM.fetch(item.fetch("couponMarketing"))
62
+ program.approval_status = Adtraction::Api::Constants::APPROVAL_STATUS_ENUM.fetch(item.fetch("approvalStatus"))
63
+ program.email_marketing = Adtraction::Api::Constants::EMAIL_MARKETING_ENUM.fetch(item.fetch("emailMarketing"))
64
+ program.sem_marketing = Adtraction::Api::Constants::SEM_MARKETING_ENUM.fetch(item.fetch("semMarketing"))
65
+ program.social_marketing = Adtraction::Api::Constants::SOCIAL_MARKETING_ENUM.fetch(item.fetch("socialMarketing"))
66
+ program.cashback_marketing = Adtraction::Api::Constants::CASHBACK_MARKETING_ENUM.fetch(item.fetch("cashbackMarketing"))
67
+ program.coupon_marketing = Adtraction::Api::Constants::COUPON_MARKETING_ENUM.fetch(item.fetch("couponMarketing"))
68
68
 
69
69
  program.compensations&.each do |compensation|
70
- enum = Adtraction::API::Constants::TRANSACTION_TYPE_ENUM.fetch(compensation["transactionType"], nil)
70
+ enum = Adtraction::Api::Constants::TRANSACTION_TYPE_ENUM.fetch(compensation["transactionType"], nil)
71
71
  compensation["transactionType"] = enum unless enum.nil?
72
72
  end
73
73
 
@@ -1,5 +1,5 @@
1
1
  module Adtraction
2
- module API
3
- VERSION = "0.1.1"
2
+ module Api
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -3,14 +3,14 @@
3
3
  require "rails/generators/base"
4
4
 
5
5
  module Adtraction
6
- module API
6
+ module Api
7
7
  module Generators
8
8
  class InstallGenerator < Rails::Generators::NamedBase
9
9
  include Rails::Generators::ResourceHelpers
10
10
 
11
11
  source_root File.expand_path('templates', __dir__)
12
12
 
13
- desc "Creates an initializer for Adtraction::API for your Rails application."
13
+ desc "Creates an initializer for Adtraction::Api for your Rails application."
14
14
 
15
15
  def copy_initializer_file
16
16
  copy_file "config.rb", "config/initializers/adtraction_api.rb"
@@ -1,3 +1,3 @@
1
- Adtraction::API.configure do |config|
1
+ Adtraction::Api.configure do |config|
2
2
  config.api_key = "ENTER_YOUR_API_KEY_HERE"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adtraction-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Johnsson