my_target_api 1.2.1 → 1.2.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
  SHA1:
3
- metadata.gz: 6baa9baf7e866577e83fe5678ae32c1250c6b2f6
4
- data.tar.gz: a06f4dff789ccff62b7954583c0eab81fb8250d4
3
+ metadata.gz: f5b3492bdf9601a076cc8aaadfea12c8c22f0930
4
+ data.tar.gz: 28f27c1b2b83cc51da6b48dec7039686651fcdbc
5
5
  SHA512:
6
- metadata.gz: 275bd343d50db2df8ea22434f502b8f4aa95990e99dbd16384597c79ef9736d12ebc7a0da0849e43bab1f38c02597bcb22972c5936f280f7fe615a452899a967
7
- data.tar.gz: 89640a388f2bb98564fc048a3c0daaaea5da79eb6eab2eefa4bb347215995bdfcf17f2679c8fcd5fb1dd0f6639925536ac71e697785874488d19a6493fb4ab15
6
+ metadata.gz: 1773b2c68b764a762090da96c27ee9eb7baa7116b9d62c99b5894e3b035feb0f7a88f45f63b64d8e53cf226d4b2a9ab5d6796767ab9a06f6520ee5a1d4c9dd7e
7
+ data.tar.gz: 4b131a598bd0e62409029e6cff9d221c1299dfb5a2c8f83ea3024f846930298f417d6c18fea99b86091de8447c0a4d6348925d343bd15c8493aaf2e8b8188574
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_target_api (1.2.0)
4
+ my_target_api (1.2.1)
5
5
  json (~> 2.0, >= 2.0.0)
6
6
  rest-client (~> 2.0, >= 2.0.0)
7
7
 
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```
10
- gem 'my_target_api', '~> 1.2.1'
10
+ gem 'my_target_api', '~> 1.2.2'
11
11
  ```
12
12
 
13
13
  Or install from command line:
@@ -15,7 +15,7 @@ class MyTargetApi
15
15
  log_hash(method: 'Request#get', url: url, params: params)
16
16
 
17
17
  response = with_exception_handling do
18
- RestClient.get(url, headers(params).merge(query(params)))
18
+ RestClient.get(url, headers.merge(query(params)))
19
19
  end
20
20
 
21
21
  process_response(response)
@@ -25,7 +25,7 @@ class MyTargetApi
25
25
  log_hash(method: 'Request#post', url: url, params: params)
26
26
 
27
27
  response = with_exception_handling do
28
- RestClient.post(url, body_parameters(params), headers(params))
28
+ RestClient.post(url, body_parameters(params), headers)
29
29
  end
30
30
 
31
31
  process_response(response)
@@ -35,7 +35,7 @@ class MyTargetApi
35
35
  log_hash(method: 'Request#delete', url: url, params: params)
36
36
 
37
37
  response = with_exception_handling do
38
- RestClient.delete(url, headers(params).merge(query(params)))
38
+ RestClient.delete(url, headers.merge(query(params)))
39
39
  end
40
40
 
41
41
  process_response(response)
@@ -45,7 +45,7 @@ class MyTargetApi
45
45
  log_hash(method: 'Request#upload', url: url, params: params, content: 'no logging')
46
46
 
47
47
  response = with_exception_handling do
48
- RestClient.post(url, content, headers(params).merge(query(params)))
48
+ RestClient.post(url, content, headers.merge(query(params)))
49
49
  end
50
50
 
51
51
  process_response(response)
@@ -57,7 +57,6 @@ class MyTargetApi
57
57
 
58
58
  def body_parameters(params)
59
59
  result_params = params.dup
60
- result_params.delete(:access_token)
61
60
 
62
61
  if result_params.values.any? { |param| param.is_a? IO } || result_params[:grant_type]
63
62
  individual_body_parameters(result_params)
@@ -72,18 +71,12 @@ class MyTargetApi
72
71
  end.to_h
73
72
  end
74
73
 
75
- def header_parameters(params)
76
- result_params = params.dup
77
- result_params.delete(:access_token)
78
- result_params
79
- end
80
-
81
74
  def query(params)
82
- { params: header_parameters(params) }
75
+ { params: params }
83
76
  end
84
77
 
85
- def headers(params)
86
- { Authorization: "Bearer #{params[:access_token]}" }
78
+ def headers
79
+ { Authorization: "Bearer #{access_token}" }
87
80
  end
88
81
 
89
82
  def process_response(response)
@@ -130,5 +123,9 @@ class MyTargetApi
130
123
  options[:logger] << message if options[:logger]
131
124
  end
132
125
 
126
+ def access_token
127
+ options[:access_token]
128
+ end
129
+
133
130
  end
134
131
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class MyTargetApi
4
4
 
5
- VERSION = '1.2.1'
5
+ VERSION = '1.2.2'
6
6
 
7
7
  end
data/lib/my_target_api.rb CHANGED
@@ -44,7 +44,7 @@ class MyTargetApi
44
44
  attr_reader :access_token, :options
45
45
 
46
46
  def request_object
47
- Request.new(logger: options[:logger])
47
+ Request.new(logger: options[:logger], access_token: access_token)
48
48
  end
49
49
 
50
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_target_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OneRetarget.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-10 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json