my_target_api 1.0.0 → 1.0.1

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: 9db7b825023cce20380d552563ddfea38b523162
4
- data.tar.gz: 3b60fc29ae1509afb23350848724aefcd1902ae6
3
+ metadata.gz: 4c0ba72363e1e3c2b93c8d571dcd528018665986
4
+ data.tar.gz: 42349e2efdfa1e10f158940125cdd4f2f277c0a3
5
5
  SHA512:
6
- metadata.gz: b78f6eeb2539f8ccf1703908e357e897045742420d558ec4640f2611e97675a28aa50f3f3ef4585d04dcac4f26a318c9bb3b0bc6d7fb18923cbc9dacd7849f3b
7
- data.tar.gz: a4190f3f66544374d16bbd9e6ccb7b383b133a441ab53fdbdca60faa05af7411d0e132280c2e31b8c7f5da9e3798ee7c6b7a430888bc37f3711d41213bc24e64
6
+ metadata.gz: 80374c7520aa036d70b3b9a26fcdb7eb16dc85cf1f59e6d183618a65140c30a28247c01399c83fa5b16889a64dd73707426e1b9db6770e0f135679a131f9b0f4
7
+ data.tar.gz: 0e55cc56d187e2c5d999c666cbdda6807ff1c686467cf26f9684d4502b92dab4dfded6615f9aea0a008e936aca0861c37ba645377cdc89d35d4279142d476047
@@ -13,11 +13,7 @@ class MyTargetApi
13
13
 
14
14
  def get(url, params = {})
15
15
  response = with_exception_handling do
16
- RestClient::Request.execute(
17
- method: :get,
18
- url: url,
19
- headers: header_parameters(params).merge(headers(params))
20
- )
16
+ RestClient.get(url, headers(params).merge(params: header_parameters(params)))
21
17
  end
22
18
 
23
19
  process_response(response)
@@ -25,26 +21,15 @@ class MyTargetApi
25
21
 
26
22
  def post(url, params = {})
27
23
  response = with_exception_handling do
28
- RestClient::Request.execute(
29
- method: :post,
30
- url: url,
31
- payload: body_parameters(params),
32
- headers: headers(params)
33
- )
24
+ RestClient.post(url, body_parameters(params), headers(params))
34
25
  end
35
26
 
36
27
  process_response(response)
37
28
  end
38
29
 
39
30
  def delete(url, params = {})
40
- result_params = params.dup
41
- result_params.delete(:access_token)
42
31
  response = with_exception_handling do
43
- RestClient::Request.execute(
44
- method: :delete,
45
- url: url,
46
- headers: header_parameters(params).merge(headers(params))
47
- )
32
+ RestClient.delete(url, headers(params).merge(params: header_parameters(params)))
48
33
  end
49
34
 
50
35
  process_response(response)
@@ -2,6 +2,6 @@
2
2
 
3
3
  class MyTargetApi
4
4
 
5
- VERSION = '1.0.0'
5
+ VERSION = '1.0.1'
6
6
 
7
7
  end
data/spec/request_spec.rb CHANGED
@@ -15,11 +15,19 @@ describe MyTargetApi::Request do
15
15
 
16
16
  describe 'request something' do
17
17
  it 'return parsed json' do
18
- stub_request(:get, 'https://target.my.com/api/v1/campaigns.json')
18
+ stub_request(:post, 'https://target.my.com/api/v1/campaigns.json')
19
19
  .to_return(body: '{"name": "Campaign 1"}')
20
20
 
21
- expect(subject.get('https://target.my.com/api/v1/campaigns.json'))
21
+ expect(subject.post('https://target.my.com/api/v1/campaigns.json'))
22
22
  .to eq('name' => 'Campaign 1')
23
23
  end
24
+
25
+ it 'pass parameters by url in get' do
26
+ stub_request(:get, 'https://target.my.com/api/v1/vk_groups.json?q=unfound')
27
+ .to_return(body: '[]')
28
+
29
+ expect(subject.get('https://target.my.com/api/v1/vk_groups.json', q: 'unfound'))
30
+ .to eq([])
31
+ end
24
32
  end
25
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_target_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reshetnikov Ivan