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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -5
- data/adtraction-api.gemspec +1 -1
- data/bin/console +2 -2
- data/lib/adtraction/api.rb +3 -3
- data/lib/adtraction/api/affiliate/channels.rb +2 -2
- data/lib/adtraction/api/affiliate/programs.rb +2 -2
- data/lib/adtraction/api/client.rb +6 -6
- data/lib/adtraction/api/configuration.rb +2 -2
- data/lib/adtraction/api/constants.rb +1 -1
- data/lib/adtraction/api/models/channel.rb +1 -1
- data/lib/adtraction/api/models/program.rb +8 -8
- data/lib/adtraction/api/version.rb +2 -2
- data/lib/generators/adtraction/api/install_generator.rb +2 -2
- data/lib/generators/adtraction/api/templates/config.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccdc5f5c644b82a99b16cb8274474b49e46a4d8c608e6ab7fb96366336d74509
|
4
|
+
data.tar.gz: a69e42f6d2652d002f3947ef8649174d501d2b4f9a3f65f67718a15927de1475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c996e20165389fe5070efd55b61dafdd91eaf9d6df90613bf03b3acf6ebf2c034879b35e8743a8d90454c5db2728d9a1d28a8e52fa9759adc406e4d8ad56295
|
7
|
+
data.tar.gz: ab3a9e8cb4372c0eb3176ec8f21e573f62c5eafd3d038fcbd968c1944516a58f77b9c992e0df23ec6f3f17682807678957aedc795e1a5b2d2997843805b8b6d2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Adtraction::
|
1
|
+
# Adtraction::Api
|
2
2
|
|
3
|
-
Adtraction::
|
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::
|
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::
|
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::
|
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).
|
data/adtraction-api.gemspec
CHANGED
@@ -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::
|
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::
|
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::
|
16
|
+
user_agent: "Adtraction Ruby Client #{::Adtraction::Api::VERSION}",
|
17
17
|
verbose: true
|
18
18
|
}
|
19
19
|
end
|
data/lib/adtraction/api.rb
CHANGED
@@ -19,18 +19,18 @@ if !String.instance_methods(false).include?(:camelize)
|
|
19
19
|
end
|
20
20
|
|
21
21
|
module Adtraction
|
22
|
-
module
|
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::
|
29
|
+
@configuration ||= ::Adtraction::Api::Configuration.new
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.reset
|
33
|
-
@configuration = ::Adtraction::
|
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
|
2
|
+
module Api
|
3
3
|
module Affiliate
|
4
4
|
module Channels
|
5
5
|
|
6
6
|
def approved_channels(path: "/affiliate/approvedchannels", options: {})
|
7
|
-
::Adtraction::
|
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
|
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::
|
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
|
2
|
+
module Api
|
3
3
|
class Client
|
4
4
|
attr_accessor :configuration
|
5
5
|
|
6
|
-
def initialize(configuration: ::Adtraction::
|
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::
|
12
|
-
include Adtraction::
|
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::
|
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::
|
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
|
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::
|
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
|
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::
|
63
|
-
program.email_marketing = Adtraction::
|
64
|
-
program.sem_marketing = Adtraction::
|
65
|
-
program.social_marketing = Adtraction::
|
66
|
-
program.cashback_marketing = Adtraction::
|
67
|
-
program.coupon_marketing = Adtraction::
|
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::
|
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
|
|
@@ -3,14 +3,14 @@
|
|
3
3
|
require "rails/generators/base"
|
4
4
|
|
5
5
|
module Adtraction
|
6
|
-
module
|
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::
|
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"
|