hasoffersv3 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1f94908bc73b00a0152fbf3ad054a776f268518
4
- data.tar.gz: 06dfd698ca5f91d43105207f0638558fc3c2993b
3
+ metadata.gz: 5e19c9439e228e95df8e9790cc5771bee7ca3442
4
+ data.tar.gz: fa1150166459c267df061da7cac6901edf39c3c5
5
5
  SHA512:
6
- metadata.gz: 93bcc4325bda19af9b1c4e3f19443dfdda45fd2fc7999a566b1b0e4ebfc48b4a1036fff65181472f6041ee84824038934ea0cb88b95f8befdce8af3cd28e81a0
7
- data.tar.gz: 5436dd964dd12c9f8226710a41787fa6cf27ab18a07157043df963191e655f3ad24c0ae56a4ce722f85373efd4589c3e2dd52498c077b3919f61a503321a5f97
6
+ metadata.gz: 9d65f052b5c37b02b885608be5edd223f481fc9fafaa52b8ca437b117badf2680853a46f745a35d1c048e5a9f83ce967140b22e190d73ae2c56f1469f5a3edc9
7
+ data.tar.gz: 0746fc08779f6cc2fff4d13ee66a020b74a184185c3f3cd0783dc031bb370a50b175410ed3f3c565a70e1dcddd55e77250b3d9e30b5d2b567284ff6a1a1facff
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # 0.1.0
2
+
3
+ - [#14] added `.find_added_conversions` and `find_updated_conversions` calls
4
+ - [#16] added protocol configuration option for API url (default is `http`)
5
+ - [#13] fixed `get_log_expirations` call
6
+ - [#15] fixed missing tests for `RawLog`
7
+
8
+ # 0.0.1
9
+
10
+ - initial release
data/README.md CHANGED
@@ -1,6 +1,17 @@
1
- # Ruby wrapper for HasOffers APIv3
1
+ ### Overview
2
2
 
3
- Gem provides wrapper around HasOffers API in version 3, [HasOffers APIv3 Documentation](http://developers.hasoffers.com/#/brand).
3
+ [![Build status](https://api.travis-ci.org/HitFox/hasoffersv3.png?branch=master)](http://travis-ci.org/HitFox/hasoffersv3)
4
+
5
+ ### Synopsis
6
+
7
+ This gem provides a wrapper around HasOffers API in version 3, [HasOffers APIv3 Documentation](http://developers.hasoffers.com/#/brand).
8
+
9
+ ### Compatibility
10
+
11
+ Supported ruby versions:
12
+
13
+ * 1.9.3
14
+ * 2.0
4
15
 
5
16
  ## Installation
6
17
 
@@ -4,7 +4,7 @@ require 'active_support/core_ext/object/to_query'
4
4
  module HasOffersV3
5
5
  class Base
6
6
  class << self
7
- def get_request(method, params, &block)
7
+ def get_request(method, params = {}, &block)
8
8
  if block.nil?
9
9
  make_request(:get, method, params)
10
10
  else
@@ -17,7 +17,7 @@ module HasOffersV3
17
17
  end
18
18
  end
19
19
 
20
- def post_request(method, params, &block)
20
+ def post_request(method, params = {}, &block)
21
21
  if block.nil?
22
22
  make_request(:post, method, params)
23
23
  else
@@ -52,6 +52,7 @@ module HasOffersV3
52
52
 
53
53
  def new_http(uri)
54
54
  http = Net::HTTP.new(uri.host, uri.port)
55
+ http.use_ssl = true if uri.scheme == 'https'
55
56
  http.read_timeout = 600
56
57
  http
57
58
  end
@@ -1,9 +1,15 @@
1
1
  module HasOffersV3
2
2
  class Configuration
3
- attr_accessor :network_id, :api_key, :base_uri
3
+ attr_accessor :network_id, :api_key, :protocol, :host, :base_path
4
4
 
5
5
  def initialize
6
- @base_uri = 'http://api.hasoffers.com/v3'
6
+ @protocol = 'http'
7
+ @host = 'api.hasoffers.com'
8
+ @base_path = '/v3'
9
+ end
10
+
11
+ def base_uri
12
+ "#{protocol}://#{host}#{base_path}"
7
13
  end
8
14
  end
9
15
  end
@@ -9,6 +9,14 @@ module HasOffersV3
9
9
  def find_all(params = {})
10
10
  get_request 'findAll', params
11
11
  end
12
+
13
+ def find_added_conversions(params = {})
14
+ get_request 'findAddedConversions', params
15
+ end
16
+
17
+ def find_updated_conversions(params = {})
18
+ get_request 'findUpdatedConversions', params
19
+ end
12
20
  end
13
21
  end
14
22
  end
@@ -6,8 +6,8 @@ module HasOffersV3
6
6
  get_request 'getDownloadLink', params
7
7
  end
8
8
 
9
- def get_log_expirations(params = {})
10
- get_request 'getLogExpirations', params
9
+ def get_log_expirations
10
+ get_request 'getLogExpirations'
11
11
  end
12
12
 
13
13
  def list_date_dirs(params = {})
@@ -1,3 +1,3 @@
1
1
  module HasOffersV3
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,9 +1,35 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe HasOffersV3::Base do
4
+ subject { HasOffersV3::Base }
5
+
6
+ let(:url) { Regexp.new api_url('Base') }
7
+
4
8
  describe :requires! do
5
9
  it 'raise ArgumentError is parameters are missing' do
6
- expect { subject.class.requires!({}, [:dummy]) }.to raise_error(ArgumentError)
10
+ expect { subject.requires!({}, [:dummy]) }.to raise_error(ArgumentError)
11
+ end
12
+ end
13
+
14
+ describe ".get_request" do
15
+ it "should make a proper request" do
16
+ stub_call :get
17
+ response = subject.get_request 'test'
18
+ a_request(:get, url).with(query: hash_including({'Method' => 'test'})).should have_been_made
19
+ validate_call response
20
+ end
21
+
22
+ context "with HTTPS enabled" do
23
+ before(:each) do
24
+ HasOffersV3.configuration.protocol = 'https'
25
+ end
26
+
27
+ it "should make a proper request" do
28
+ stub_call :get
29
+ response = subject.get_request 'test'
30
+ a_request(:get, url).with(query: hash_including({'Method' => 'test'})).should have_been_made
31
+ validate_call response
32
+ end
7
33
  end
8
34
  end
9
35
  end
@@ -17,6 +17,22 @@ describe HasOffersV3::Conversion do
17
17
  end
18
18
  end
19
19
 
20
+ describe '.find_added_conversions' do
21
+ it 'should make a proper request call' do
22
+ response = subject.find_added_conversions
23
+ a_request(:get, url).with(query: hash_including({'Method' => 'findAddedConversions'})).should have_been_made
24
+ validate_call response
25
+ end
26
+ end
27
+
28
+ describe '.find_updated_conversions' do
29
+ it 'should make a proper request call' do
30
+ response = subject.find_updated_conversions
31
+ a_request(:get, url).with(query: hash_including({'Method' => 'findUpdatedConversions'})).should have_been_made
32
+ validate_call response
33
+ end
34
+ end
35
+
20
36
  describe '.findAll' do
21
37
  it 'should make a proper request call' do
22
38
  response = subject.findAll
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe HasOffersV3::RawLog do
4
+ subject { HasOffersV3::RawLog }
5
+
6
+ let(:url) { Regexp.new api_url('RawLog') }
7
+
8
+ before :each do
9
+ stub_call :get
10
+ end
11
+
12
+ describe '.get_download_link' do
13
+ it 'should make a proper request call' do
14
+ response = subject.get_download_link log_type: 'clicks', log_filename: 'xxx'
15
+ a_request(:get, url).with(query: hash_including({'Method' => 'getDownloadLink'})).should have_been_made
16
+ validate_call response
17
+ end
18
+
19
+ context 'when there is no log_type' do
20
+ it 'it should raise an exception' do
21
+ expect { subject.get_download_link log_filename: 'xxx' }.to raise_error ArgumentError
22
+ end
23
+ end
24
+
25
+ context 'when there is no log_filename' do
26
+ it 'it should raise an exception' do
27
+ expect { subject.get_download_link log_type: 'clicks' }.to raise_error ArgumentError
28
+ end
29
+ end
30
+ end
31
+
32
+ describe '.get_log_expirations' do
33
+ it 'should make a proper request call' do
34
+ response = subject.get_log_expirations
35
+ a_request(:get, url).with(query: hash_including({'Method' => 'getLogExpirations'})).should have_been_made
36
+ validate_call response
37
+ end
38
+ end
39
+
40
+ describe '.list_date_dirs' do
41
+ it 'should make a proper request call' do
42
+ response = subject.list_date_dirs log_type: 'clicks'
43
+ a_request(:get, url).with(query: hash_including({'Method' => 'listDateDirs'})).should have_been_made
44
+ validate_call response
45
+ end
46
+
47
+ context 'when there is no log_type' do
48
+ it 'it should raise an exception' do
49
+ expect { subject.list_date_dirs }.to raise_error ArgumentError
50
+ end
51
+ end
52
+ end
53
+
54
+ describe '.list_logs' do
55
+ it 'should make a proper request call' do
56
+ response = subject.list_logs log_type: 'clicks', date_dir: '20140101'
57
+ a_request(:get, url).with(query: hash_including({'Method' => 'listLogs'})).should have_been_made
58
+ validate_call response
59
+ end
60
+
61
+ context 'when there is no log_type' do
62
+ it 'it should raise an exception' do
63
+ expect { subject.list_logs date_dir: '20140101' }.to raise_error ArgumentError
64
+ end
65
+ end
66
+
67
+ context 'when there is no date_dir' do
68
+ it 'it should raise an exception' do
69
+ expect { subject.list_logs log_type: 'clicks' }.to raise_error ArgumentError
70
+ end
71
+ end
72
+ end
73
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hasoffersv3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maximilian Seifert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-19 00:00:00.000000000 Z
12
+ date: 2014-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oj
@@ -107,6 +107,7 @@ files:
107
107
  - .rspec
108
108
  - .ruby-gemset
109
109
  - .ruby-version
110
+ - CHANGELOG.md
110
111
  - Gemfile
111
112
  - LICENSE.txt
112
113
  - README.md
@@ -131,6 +132,7 @@ files:
131
132
  - spec/lib/base_spec.rb
132
133
  - spec/lib/conversion_spec.rb
133
134
  - spec/lib/offer_spec.rb
135
+ - spec/lib/raw_log_spec.rb
134
136
  - spec/lib/report_spec.rb
135
137
  - spec/spec_helper.rb
136
138
  homepage:
@@ -164,5 +166,6 @@ test_files:
164
166
  - spec/lib/base_spec.rb
165
167
  - spec/lib/conversion_spec.rb
166
168
  - spec/lib/offer_spec.rb
169
+ - spec/lib/raw_log_spec.rb
167
170
  - spec/lib/report_spec.rb
168
171
  - spec/spec_helper.rb