avangate 0.1.9 → 0.2.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: 6e1e53844fdb5c21cb565db3b918694abf4cf432
4
- data.tar.gz: c1a03f083dbbe0902625d9aaa3e1ed79c8434650
3
+ metadata.gz: 6e951889b538b35a77ca6e5c03fcf52b451e68ff
4
+ data.tar.gz: b63fbfae1715e0958f49f5546ac7977d84c85e24
5
5
  SHA512:
6
- metadata.gz: 5dd773a6a2b1c22f188c5d1088d53d563c23c66edeff15af45e8885ed4664580ae607e38d9007637d75f25e503d1c5bbe523745d0d5ec7ca8308f15f91d067ef
7
- data.tar.gz: 6bd60df22dfa289b09237a3776fbdf2fba1ac4fe963f15a9635581dbc98f5e8631c4cf4502f20f062a526f79a9f6deaa4da2606ec9f274df5e1d15f006e4c1ac
6
+ metadata.gz: 0d9e1a012eb89fa29013d745a58b68f81237e5b155f828994c80b3f1c97cfd9833fd7e66d1d528c14ac53f1e3df9816a1a5db367488c4a6965ea262474994930
7
+ data.tar.gz: 72ba7d7c28d51e8745ce9432093475f86c96407e5be1ba28044c9fe749e866f3f628b2691075d6229be8639a24a68677c25cb964a5f55dffd5d2c5e8052ddefd
data/README.md CHANGED
@@ -5,6 +5,7 @@ This gem is a library to interact with Avangate SOAP API
5
5
  Current methods implemented:
6
6
 
7
7
  #login
8
+ #addProduct
8
9
 
9
10
  ## Installation
10
11
 
@@ -33,7 +34,8 @@ Inside you can and set up:
33
34
 
34
35
  ## Usage
35
36
 
36
- sessionId = Avangate::SOAP.login
37
+ @sessionId = Avangate::SOAP.login
38
+ Avangate::SOAP.add_product({session_id: @sessionId, product_id: 423221})
37
39
 
38
40
  ## Development
39
41
 
data/lib/avangate.rb CHANGED
@@ -6,6 +6,7 @@ require "avangate/errors"
6
6
  module Avangate
7
7
 
8
8
  END_POINT = 'https://api.avangate.com/order/2.3/soap/?wsdl'
9
+ STATE_REQUIRED_COUNTRIES = ['US','RO','BR']
9
10
 
10
11
  class SOAP
11
12
  def self.login
@@ -31,6 +32,34 @@ module Avangate
31
32
  return response.body.first[1].first[1]
32
33
  end
33
34
 
35
+ def self.set_billing_details(options={})
36
+ raise MissingSessionId, "missing param session_id" unless options[:session_id].presence
37
+ raise MissingAddress, "missing param address" unless options[:address].presence
38
+ raise MissingCity, "missing param city" unless options[:city].presence
39
+ raise MissingCountry, "missing param country" unless options[:country].presence
40
+ raise MissingEmail, "missing param email" unless options[:email].presence
41
+ raise MissingFirstName, "missing param first_name" unless options[:first_name].presence
42
+ raise MissingLastName, "missing param last_name" unless options[:last_name].presence
43
+ raise MissingPostalCode, "missing param postal_code" unless options[:postal_code].presence
44
+ raise MissingState, "missing param state" unless options[:postal_code].presence or !STATE_REQUIRED_COUNTRIES.include? options[:country]
45
+ billing_details = {
46
+ Address: options[:address],
47
+ City: options[:city],
48
+ Country: options[:email],
49
+ Email: options[:email],
50
+ FirstName: options[:first_name],
51
+ LastName: options[:last_name],
52
+ PostalCode: options[:postal_code],
53
+ State: options[:postal_code]
54
+ }
55
+ params = {
56
+ sessionID: options[:session_id],
57
+ BillingDetails: billing_details
58
+ }
59
+ response = client.call :set_billing_details, message: params
60
+ return response.body.first[1].first[1]
61
+ end
62
+
34
63
  private
35
64
 
36
65
  def self.client
@@ -12,4 +12,12 @@ module Avangate
12
12
  class MissingMerchantCode < AvangateError; end
13
13
  class MissingSessionId < AvangateError; end
14
14
  class MissingProductId < AvangateError; end
15
+ class MissingAddress < AvangateError; end
16
+ class MissingCity < AvangateError; end
17
+ class MissingCountry < AvangateError; end
18
+ class MissingEmail < AvangateError; end
19
+ class MissingFirstName < AvangateError; end
20
+ class MissingLastName < AvangateError; end
21
+ class MissingPostalCode < AvangateError; end
22
+ class MissingState < AvangateError; end
15
23
  end
@@ -1,3 +1,3 @@
1
1
  module Avangate
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avangate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo