avangate 0.1.9 → 0.2.0
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 +4 -4
- data/README.md +3 -1
- data/lib/avangate.rb +29 -0
- data/lib/avangate/errors.rb +8 -0
- data/lib/avangate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e951889b538b35a77ca6e5c03fcf52b451e68ff
|
4
|
+
data.tar.gz: b63fbfae1715e0958f49f5546ac7977d84c85e24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/avangate/errors.rb
CHANGED
@@ -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
|
data/lib/avangate/version.rb
CHANGED