hasoffers 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,10 @@
1
+ == Version 0.1.6
2
+ * Fix issues with error hash on Response object
3
+ * Fix issues that occur when sending GET requests over a proxy, switched
4
+ to POST params where possible
5
+
1
6
  == Version 0.1.4
2
- * Create a class method to get and set the @@base_uri, with tests
7
+ * Create a class method to get and set the @@base_uri, with tests
3
8
 
4
9
  == Version 0.1.3
5
10
  * Bug fix - it's possible for AffiliateBilling to return an array of nil, instead
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hasoffers (0.1.4)
4
+ hasoffers (0.1.6)
5
5
  crack
6
6
  yajl-ruby
7
7
 
@@ -7,7 +7,7 @@ module HasOffers
7
7
  class << self
8
8
 
9
9
  def find_all(params = {})
10
- get_request(Target, 'findAll', params)
10
+ post_request(Target, 'findAll', params)
11
11
  end
12
12
 
13
13
  def create(data, return_object = false)
@@ -26,4 +26,4 @@ module HasOffers
26
26
 
27
27
  end
28
28
 
29
- end
29
+ end
@@ -6,9 +6,12 @@ module HasOffers
6
6
 
7
7
  class << self
8
8
 
9
+ # Jon Phenow @ 06/13/12
10
+ # Switched this to use POST because of some weird issues with sending
11
+ # from behind a proxy
9
12
  def find_invoice_stats(params)
10
13
  requires!(params, %w[affiliate_id end_date])
11
- get_request(Target, 'findInvoiceStats', params)
14
+ post_request(Target, 'findInvoiceStats', params)
12
15
  end
13
16
 
14
17
  def simplify_response_data data
@@ -22,8 +25,11 @@ module HasOffers
22
25
  data.map { |id, invoice_data| invoice_data["AffiliateInvoice"] }
23
26
  end
24
27
 
28
+ # Jon Phenow @ 06/13/12
29
+ # Switched this to use POST because of some weird issues with sending
30
+ # from behind a proxy
25
31
  def find_all_invoices(params)
26
- response = get_request(Target, 'findAllInvoices', params)
32
+ response = post_request(Target, 'findAllInvoices', params)
27
33
  if response.success?
28
34
  # strip out the clutter
29
35
  response.set_data simplify_response_data(response.data)
@@ -31,9 +37,12 @@ module HasOffers
31
37
  response
32
38
  end
33
39
 
40
+ # Jon Phenow @ 06/13/12
41
+ # Switched this to use POST because of some weird issues with sending
42
+ # from behind a proxy
34
43
  def find_all_invoices_by_ids(ids, params = {})
35
44
  params['ids'] = ids
36
- response = get_request(Target, 'findAllInvoicesByIds', params)
45
+ response = post_request(Target, 'findAllInvoicesByIds', params)
37
46
  if response.success?
38
47
  # strip out the clutter
39
48
  response.set_data simplify_response_data(response.data)
@@ -57,4 +66,4 @@ module HasOffers
57
66
 
58
67
  end
59
68
 
60
- end
69
+ end
@@ -6,9 +6,12 @@ module HasOffers
6
6
 
7
7
  class << self
8
8
 
9
+ # Jon Phenow @ 06/13/12
10
+ # Switched this to use POST because of some weird issues with sending
11
+ # from behind a proxy
9
12
  def get_stats(params)
10
13
  requires!(params, %w[fields])
11
- response = get_request(Target, 'getStats', params)
14
+ response = post_request(Target, 'getStats', params)
12
15
  if response.success?
13
16
  # strip out the 'Stat' keys which is just extra clutter
14
17
  data = response.data.map do |stat|
@@ -19,8 +22,11 @@ module HasOffers
19
22
  response
20
23
  end
21
24
 
25
+ # Jon Phenow @ 06/13/12
26
+ # Switched this to use POST because of some weird issues with sending
27
+ # from behind a proxy
22
28
  def get_conversions(params)
23
- response = get_request(Target, 'getConversions', params)
29
+ response = post_request(Target, 'getConversions', params)
24
30
  if response.success?
25
31
  # strip out the 'Stat' keys which is just extra clutter
26
32
  data = response.data.map do |stat|
@@ -35,4 +41,4 @@ module HasOffers
35
41
 
36
42
  end
37
43
 
38
- end
44
+ end
@@ -1,7 +1,5 @@
1
1
  module HasOffers
2
-
3
2
  class Response
4
-
5
3
  attr_reader :test, :body, :http_status_code, :http_message, :http_headers
6
4
 
7
5
  def success?
@@ -56,9 +54,9 @@ module HasOffers
56
54
 
57
55
  def error_messages
58
56
  if data.is_a? Hash and data["errors"] and data["errors"]["error"]
59
- data["errors"]["error"].map { |error| error["err_msg"] }
57
+ get_error_values data["errors"]["error"]
60
58
  elsif @body["response"]["errors"]
61
- @body["response"]["errors"].map { |error| error["err_msg"] }
59
+ get_error_values @body["response"]["errors"]
62
60
  else
63
61
  []
64
62
  end
@@ -83,6 +81,14 @@ module HasOffers
83
81
  @body['response']['data'] and @body['response']['data'].is_a?(Hash) and @body['response']['data'].has_key?('pageCount')
84
82
  end
85
83
 
86
- end
84
+ private
87
85
 
88
- end
86
+ def get_error_values(obj)
87
+ if obj.is_a? Hash
88
+ obj.values
89
+ elsif obj.is_a? Array
90
+ obj.map { |error| error["err_msg"] || error["publicMessage"] }
91
+ end
92
+ end
93
+ end
94
+ end
@@ -1,3 +1,3 @@
1
1
  module Hasoffers
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hasoffers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-02 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crack
16
- requirement: &70102351422880 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70102351422880
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: yajl-ruby
27
- requirement: &70102351438360 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70102351438360
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &70102351435880 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,7 +53,12 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70102351435880
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  description: Implementation of the HasOffers API for affiliate advertising.
48
63
  email:
49
64
  - luke.ludwig@tstmedia.com
@@ -91,15 +106,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
106
  - - ! '>='
92
107
  - !ruby/object:Gem::Version
93
108
  version: '0'
109
+ segments:
110
+ - 0
111
+ hash: 869840649197282084
94
112
  required_rubygems_version: !ruby/object:Gem::Requirement
95
113
  none: false
96
114
  requirements:
97
115
  - - ! '>='
98
116
  - !ruby/object:Gem::Version
99
117
  version: '0'
118
+ segments:
119
+ - 0
120
+ hash: 869840649197282084
100
121
  requirements: []
101
122
  rubyforge_project: hasoffers
102
- rubygems_version: 1.8.17
123
+ rubygems_version: 1.8.24
103
124
  signing_key:
104
125
  specification_version: 3
105
126
  summary: Implementation of the HasOffers API for affiliate advertising.