gotransverse-tract-api 0.6.7 → 0.7.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: b3fafc4875081e96d6ffd3a49fd602168f17cdb8
4
- data.tar.gz: fc8250030e4563cfdae7e82ed2c7fd79f3a73209
3
+ metadata.gz: 9a10cb2e5d1d257a44a6ad91b9a7bf7c92138b82
4
+ data.tar.gz: a8cfcda85e4cbc4eb9dce8ab1505e74c2608b4a5
5
5
  SHA512:
6
- metadata.gz: d3386e418c4cd4ac4585b37729992c6c55780d2a8794c23c6324566e75da3aac8839fdc9c3b5be243b9a19f290779fbee7f55c27a0c0c0ad1b7927759c88bc61
7
- data.tar.gz: 70ee8ddf396d4456128e7e4a0cec2e335c94feafabe4fb034717da20bee845d8609a1b948ca3e090ed5e79ad38122dc15eaac1dae91a6969b912dfda457cbaec
6
+ metadata.gz: 89b562638e192cd8ba89e5452e6eef00c161a3b3436b5eadfd16bfd1f6263c87a274035dd03c57c87c22a11c46f898823f0cd64205f5bd868c04f45af2998b7a
7
+ data.tar.gz: 0c861f5b9ab8f761565f6d20f605b71d2de6a3c6174433f52150be3769644cba5556c855934fed8f12bc87cb0d87b3dff282f9cfacaf7b2eafda458e5b0b29e5
@@ -178,7 +178,8 @@ module GoTransverseTractApi
178
178
  #
179
179
  def self.put_request_for(klass, api_params={}, request_body)
180
180
  api_url = GoTransverseTractApi.get_api_url_for(klass)
181
- self.call(klass, api_url, api_params, :put, request_body.to_xml)
181
+ api_url = api_url + "/#{api_params[:eid]}"
182
+ self.call(klass, api_url, api_params, :put, request_body)
182
183
  end
183
184
 
184
185
  #
@@ -268,7 +269,7 @@ module GoTransverseTractApi
268
269
  when :post
269
270
  response = http_client.post(api_url, request_body, {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
270
271
  when :put
271
- response = http_client.put(api_url, request_body, api_params)
272
+ response = http_client.put(api_url, request_body, {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
272
273
  when :delete
273
274
  response = http_client.delete(api_url, request_body, {'Content-Type' => 'application/xml', 'Accept' => 'application/xml'})
274
275
  end
@@ -229,22 +229,36 @@ module GoTransverseTractApi
229
229
 
230
230
  def get_addresses(entity)
231
231
  addresses = {
232
- attributes: {},
233
- emailAddress: {
234
- purpose: entity[:addresses][:email_address][:purpose],
235
- email: entity[:addresses][:email_address][:email],
236
- }.delete_if{|k,v| v.nil?},
237
- postalAddress: {
238
- purpose: entity[:addresses][:postal_address][:purpose],
239
- country: entity[:addresses][:postal_address][:country],
240
- city: entity[:addresses][:postal_address][:city],
241
- regionOrState: entity[:addresses][:postal_address][:region_or_state],
242
- attention: entity[:addresses][:postal_address][:attention],
243
- postalCode: entity[:addresses][:postal_address][:postal_code],
244
- line1: entity[:addresses][:postal_address][:line1],
245
- }.delete_if{|k,v| v.nil?}
232
+ attributes: {}
246
233
  }
247
234
 
235
+ if entity[:addresses].has_key?(:email_address)
236
+ email_address = {
237
+ emailAddress: {
238
+ purpose: entity[:addresses][:email_address][:purpose],
239
+ email: entity[:addresses][:email_address][:email],
240
+ }.delete_if{|k,v| v.nil?}
241
+ }.delete_if{|k,v| v.nil?}
242
+
243
+ addresses.merge! email_address if email_address.present?
244
+ end
245
+
246
+ if entity[:addresses].has_key?(:postal_address)
247
+ postal_address = {
248
+ postalAddress: {
249
+ purpose: entity[:addresses][:postal_address][:purpose],
250
+ country: entity[:addresses][:postal_address][:country],
251
+ city: entity[:addresses][:postal_address][:city],
252
+ regionOrState: entity[:addresses][:postal_address][:region_or_state],
253
+ attention: entity[:addresses][:postal_address][:attention],
254
+ postalCode: entity[:addresses][:postal_address][:postal_code],
255
+ line1: entity[:addresses][:postal_address][:line1],
256
+ }.delete_if{|k,v| v.nil?}
257
+ }.delete_if{|k,v| v.nil?}
258
+
259
+ addresses.merge! postal_address if postal_address.present?
260
+ end
261
+
248
262
  if entity[:addresses].has_key?(:telecom_address)
249
263
  tele_address = {
250
264
  telecomAddress: {
@@ -256,9 +270,9 @@ module GoTransverseTractApi
256
270
  purpose: entity[:addresses].try(:[],:telecom_address).try(:[],:purpose),
257
271
  eid: entity[:addresses].try(:[],:telecom_address).try(:[],:eid)
258
272
  }.delete_if{|k,v| v.nil?}
259
- }
273
+ }.delete_if{|k,v| v.nil?}
260
274
 
261
- addresses.merge! tele_address
275
+ addresses.merge! tele_address if tele_address.present?
262
276
  end
263
277
 
264
278
  addresses
@@ -377,6 +377,23 @@ module GoTransverseTractApi
377
377
  GoTransverseTractApi.put_request_for(self, {eid: eid}, xml_data)
378
378
  end
379
379
 
380
+ # @param {Long} eid
381
+ # @param {Hash} billing_account
382
+ #
383
+ def update_address eid, billing_account
384
+ data = {
385
+ billingAccount: {
386
+ eid: eid,
387
+ billType: billing_account[:bill_type],
388
+ automaticRecurringPayment: billing_account[:automatic_recurring_payment]
389
+ },
390
+ addresses: GoTransverseTractApi::ApiData.new.get_addresses(billing_account)
391
+ }
392
+
393
+ xml_data = GoTransverseTractApi.generateXML(data, 'billingAccount')
394
+ GoTransverseTractApi.put_request_for(self, {eid: eid}, xml_data)
395
+ end
396
+
380
397
  private
381
398
 
382
399
  def get_products(billing_account)
@@ -1,6 +1,6 @@
1
1
  module GoTransverseTractApi
2
2
 
3
- VERSION = "0.6.7"
3
+ VERSION = "0.7.0"
4
4
  TARGET_API_VERSION = "1.29"
5
5
 
6
6
  end
@@ -296,8 +296,6 @@ module GoTransverseTractApi
296
296
  }
297
297
  }
298
298
  it "creates a draft sales order without a promo code for the billing account" do
299
- described_class.create_draft_order(eid, data)
300
-
301
299
  allow(subject).to receive(:create_draft_order).with(eid, data).and_return(response)
302
300
  expect(subject.create_draft_order(eid, data)).to eq(response)
303
301
  end
@@ -331,5 +329,19 @@ module GoTransverseTractApi
331
329
  end
332
330
  end
333
331
 
332
+ context ".update_address" do
333
+ it "updates a billing account address" do
334
+ data = {
335
+ eid: eid,
336
+ bill_type: 'NONE',
337
+ automatic_recurring_payment: 'true',
338
+ addresses: addresses.delete_if{|k,v| k == :email_address}
339
+ }
340
+
341
+ allow(subject).to receive(:update_address).with(eid, data).and_return(response)
342
+ expect(subject.update_address(eid, data)).to eq(response)
343
+ end
344
+ end
345
+
334
346
  end
335
347
  end
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.7
4
+ version: 0.7.0
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-17 00:00:00.000000000 Z
12
+ date: 2016-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler