gotransverse-tract-api 0.6.6 → 0.6.7

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: 25f10860ad89fa5f3dae30427dd15979a337ecb2
4
- data.tar.gz: 1e2e57e4dcf799e18879e571776ca56565f5b641
3
+ metadata.gz: b3fafc4875081e96d6ffd3a49fd602168f17cdb8
4
+ data.tar.gz: fc8250030e4563cfdae7e82ed2c7fd79f3a73209
5
5
  SHA512:
6
- metadata.gz: 340b5deaf83bdc7765ead44857e7952bd8039dae0fd87dd2e0c4f7bbec0b2a27e31ed59a52900916a1f589488ea005049dccffa51fe8ef0b7f937366d2695887
7
- data.tar.gz: 7b2f19a942804c34bd7d3fc1b1cd1bad3993a935b2c775b3a4fbe8630c55eb9e561795340a8f489066cb428cf48aed7e4c1b027f8a5a08e3d7333ae220da736d
6
+ metadata.gz: d3386e418c4cd4ac4585b37729992c6c55780d2a8794c23c6324566e75da3aac8839fdc9c3b5be243b9a19f290779fbee7f55c27a0c0c0ad1b7927759c88bc61
7
+ data.tar.gz: 70ee8ddf396d4456128e7e4a0cec2e335c94feafabe4fb034717da20bee845d8609a1b948ca3e090ed5e79ad38122dc15eaac1dae91a6969b912dfda457cbaec
@@ -190,6 +190,8 @@ module GoTransverseTractApi
190
190
  #
191
191
  def self.delete_request_for(klass, api_params={}, request_body)
192
192
  api_url = GoTransverseTractApi.get_api_url_for(klass)
193
+ api_url = api_url + "/#{api_params[:eid]}"
194
+
193
195
  self.call(klass, api_url, api_params, :delete, request_body)
194
196
  end
195
197
 
@@ -268,7 +270,6 @@ module GoTransverseTractApi
268
270
  when :put
269
271
  response = http_client.put(api_url, request_body, api_params)
270
272
  when :delete
271
- api_url = api_url + "/#{api_params[:eid]}"
272
273
  response = http_client.delete(api_url, request_body, {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
273
274
  end
274
275
 
@@ -1,6 +1,6 @@
1
1
  module GoTransverseTractApi
2
2
 
3
- VERSION = "0.6.6"
3
+ VERSION = "0.6.7"
4
4
  TARGET_API_VERSION = "1.29"
5
5
 
6
6
  end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+ require 'net/http'
3
+
4
+ RSpec.describe GoTransverseTractApi do
5
+ before(:each) { http_auth }
6
+
7
+ let(:klass) { 'test' }
8
+ let(:params) { {a: 'b'} }
9
+ let(:api_url) { "https://test.com" }
10
+ let(:body) { "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" }
11
+ let(:response) { "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" }
12
+
13
+ context ".call" do
14
+ it "returns success for Net HTTP Client request" do
15
+ uri = URI.parse("http://www.example.com/")
16
+ req = Net::HTTP::Get.new(uri.path)
17
+ req['Content-Length'] = 3
18
+
19
+ res = Net::HTTP.start(uri.host,uri.port) do|http|
20
+ http.request(req, 'abc')
21
+ end
22
+
23
+ expect(res.code).to eq('400')
24
+ end
25
+ end
26
+
27
+ context ".get_response_for" do
28
+ it "calls the get response" do
29
+ method = :get
30
+
31
+ allow(subject).to receive(:get_api_url).with(klass,params).and_return(api_url)
32
+ expect(subject.get_api_url(klass,params)).to eq(api_url)
33
+
34
+ allow(subject).to receive(:call).with(klass,api_url,params,method).and_return(response)
35
+ expect(subject.call(klass,api_url,params,method)).to eq(response)
36
+ end
37
+ end
38
+
39
+ context ".post_request_for" do
40
+ it "calls the post request" do
41
+ method = :post
42
+
43
+ allow(subject).to receive(:get_api_url).with(klass,params).and_return(api_url)
44
+ expect(subject.get_api_url(klass,params)).to eq(api_url)
45
+
46
+ allow(subject).to receive(:call).with(klass,api_url,params,method,body).and_return(response)
47
+ expect(subject.call(klass,api_url,params,method,body)).to eq(response)
48
+ end
49
+ end
50
+
51
+ context ".put_request_for" do
52
+ it "calls the put request" do
53
+ method = :put
54
+
55
+ allow(subject).to receive(:get_api_url).with(klass,params).and_return(api_url)
56
+ expect(subject.get_api_url(klass,params)).to eq(api_url)
57
+
58
+ allow(subject).to receive(:call).with(klass,api_url,params,method,body).and_return(response)
59
+ expect(subject.call(klass,api_url,params,method,body)).to eq(response)
60
+ end
61
+ end
62
+
63
+ context ".delete_request_for" do
64
+ it "calls the delete request" do
65
+ method = :delete
66
+
67
+ allow(subject).to receive(:get_api_url).with(klass,params).and_return(api_url)
68
+ expect(subject.get_api_url(klass,params)).to eq(api_url)
69
+
70
+ allow(subject).to receive(:call).with(klass,api_url,params,method,body).and_return(response)
71
+ expect(subject.call(klass,api_url,params,method,body)).to eq(response)
72
+ end
73
+ end
74
+
75
+ context ".generateXML" do
76
+ it "generates XML for the given hash object" do
77
+ response = "<root xmlns='http://www.tractbilling.com/billing/1_29/domain'>\n <element1 x='y' y='z'/>\n <element2 a='b'>\n <children c='d' e='f'/>\n </element2>\n</root>"
78
+
79
+ h = {
80
+ root: {},
81
+ element1: {x: 'y', y: 'z'},
82
+ element2: {
83
+ attributes: {a: 'b'},
84
+ children: {c: 'd', e: 'f'}
85
+ }
86
+ }
87
+
88
+ actual_response = described_class.generateXML(h, 'root')
89
+ expect(actual_response).to eq(response)
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotransverse-tract-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien DeFrance
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-16 00:00:00.000000000 Z
12
+ date: 2016-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -232,6 +232,7 @@ files:
232
232
  - spec/gotransverse-tract-api/usage/order_item_usage_rule_spec.rb
233
233
  - spec/gotransverse-tract-api/usage/product_usage_rule_spec.rb
234
234
  - spec/gotransverse-tract-api/usage/usage_event_spec.rb
235
+ - spec/gotransverse-tract-api_spec.rb
235
236
  - spec/spec_helper.rb
236
237
  homepage: https://rubygems.org/gems/gotransverse-tract-api
237
238
  licenses:
@@ -285,4 +286,5 @@ test_files:
285
286
  - spec/gotransverse-tract-api/usage/order_item_usage_rule_spec.rb
286
287
  - spec/gotransverse-tract-api/usage/product_usage_rule_spec.rb
287
288
  - spec/gotransverse-tract-api/usage/usage_event_spec.rb
289
+ - spec/gotransverse-tract-api_spec.rb
288
290
  - spec/spec_helper.rb