avangate 0.2.2 → 0.2.4

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: d002376589083c286d766dee792fcf63d3082d9b
4
- data.tar.gz: 1521606de3a75661f4d7a93631325fba17ab376c
3
+ metadata.gz: b886c3978f5213168be5a7fdfe9bd22f0731a949
4
+ data.tar.gz: 635d0feb131998e549802d9f251763958fab33b7
5
5
  SHA512:
6
- metadata.gz: 46cb2e49bc84d00cba364b112743f77b846636656976bd62a607b3c2af2e5c86937568b40cf0868fcfb0e12d0ef746335fdce851e8d5edf8230af4bb680de196
7
- data.tar.gz: ee6af5a52033a999ab4a259a08c1bb0178e846cd158698496a27f74a14a9366320895c663017355ed775f2ac33822f0075cd6bfc907b2cb514a2f9f4de57c470
6
+ metadata.gz: bb9bffd522fe3de4f651d0ecabf504958c33c8830b5708028623863e3cdfa7dfdb052c4b74f06aa7ff04f5b77448158509fb119cf33f1b57f98f161cac44deca
7
+ data.tar.gz: f15e211c860a83df6c9e35fb91486c5b8035353348cebd984657d95a1d0c4b6d58f2b58a5c7e806de0b9e5ea00b64e991aed751333f6e021431c7516ef70446e
data/README.md CHANGED
@@ -6,6 +6,7 @@ Current methods implemented:
6
6
 
7
7
  #login
8
8
  #addProduct
9
+ #setBillingDetails
9
10
 
10
11
  ## Installation
11
12
 
@@ -36,6 +37,17 @@ Inside you can and set up:
36
37
 
37
38
  @sessionId = Avangate::SOAP.login
38
39
  Avangate::SOAP.add_product({session_id: @sessionId, product_id: 423221})
40
+ Avangate::SOAP.set_billing_details({
41
+ session_id: @sessionId,
42
+ address: '4 street',
43
+ city: 'dream city',
44
+ country: 'US',
45
+ email: 'john.doe@example.com',
46
+ first_name: 'John',
47
+ last_name: 'Doe',
48
+ postal_code: '12333',
49
+ state: 'Alabama'
50
+ })
39
51
 
40
52
  ## Development
41
53
 
@@ -19,48 +19,67 @@ module Avangate
19
19
  end
20
20
 
21
21
  def self.add_product(options={})
22
- raise MissingSessionId, "missing param session_id" unless options[:session_id].presence
23
- raise MissingProductId, "missing param product_id" unless options[:product_id].presence
24
- quantity = options[:quantity].presence ? options[:quantity] : 1
25
- params = {
26
- sessionID: options[:session_id],
27
- ProductId: options[:product_id],
28
- Quantity: quantity
29
-
30
- }
31
- response = client.call :add_product, message: params
22
+ @options = options
23
+ require_session_id
24
+ require_product_id
25
+ response = client.call :add_product, message: add_product_params
32
26
  return response.body.first[1].first[1]
33
27
  end
34
28
 
35
29
  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[:state].presence or !STATE_REQUIRED_COUNTRIES.include? options[:country]
45
- billing_details = {}
46
- billing_details['Address'] = options[:address]
47
- billing_details['City'] = options[:city]
48
- billing_details['Country'] = options[:country]
49
- billing_details['Email'] = options[:email]
50
- billing_details['FirstName'] = options[:first_name]
51
- billing_details['LastName'] = options[:last_name]
52
- billing_details['PostalCode'] = options[:postal_code]
53
- billing_details['State'] = options[:state]
54
- params = {
55
- sessionID: options[:session_id],
56
- BillingDetails: billing_details
57
- }
58
- response = client.call :set_billing_details, message: params
30
+ @options = options
31
+ require_session_id
32
+ require_set_billing_details_params
33
+ response = client.call :set_billing_details, message: set_billing_details_params
34
+ return response.body.first[1].first[1]
35
+ end
36
+
37
+ def self.get_product_by_code(options={})
38
+ @options = options
39
+ require_session_id
40
+ require_product_code
41
+ response = client.call :get_product_by_code, message: get_product_by_code_params
59
42
  return response.body.first[1].first[1]
60
43
  end
61
44
 
62
45
  private
63
46
 
47
+ def self.require_session_id
48
+ raise MissingSessionId, "missing param session_id" unless @options[:session_id]
49
+ end
50
+
51
+ def self.require_product_id
52
+ raise MissingProductId, "missing param product_id" unless @options[:product_id]
53
+ end
54
+
55
+ def self.require_product_code
56
+ raise MissingProductCode, "missing param product_code" unless @options[:product_code]
57
+ end
58
+
59
+ def self.require_set_billing_details_params
60
+ raise MissingAddress, "missing param address" unless @options[:address]
61
+ raise MissingCity, "missing param city" unless @options[:city]
62
+ raise MissingCountry, "missing param country" unless @options[:country]
63
+ raise MissingEmail, "missing param email" unless @options[:email]
64
+ raise MissingFirstName, "missing param first_name" unless @options[:first_name]
65
+ raise MissingLastName, "missing param last_name" unless @options[:last_name]
66
+ raise MissingPostalCode, "missing param postal_code" unless @options[:postal_code]
67
+ raise MissingState, "missing param state" unless @options[:state] or !STATE_REQUIRED_COUNTRIES.include? @options[:country]
68
+ end
69
+
70
+ def self.billing_details
71
+ billing_details = {}
72
+ billing_details['Address'] = @options[:address]
73
+ billing_details['City'] = @options[:city]
74
+ billing_details['Country'] = @options[:country]
75
+ billing_details['Email'] = @options[:email]
76
+ billing_details['FirstName'] = @options[:first_name]
77
+ billing_details['LastName'] = @options[:last_name]
78
+ billing_details['PostalCode'] = @options[:postal_code]
79
+ billing_details['State'] = @options[:state]
80
+ billing_details
81
+ end
82
+
64
83
  def self.client
65
84
  @client ||= Savon.client(wsdl: END_POINT)
66
85
  end
@@ -73,6 +92,29 @@ module Avangate
73
92
  }
74
93
  end
75
94
 
95
+ def self.add_product_params
96
+ quantity = @options[:quantity] ? @options[:quantity] : 1
97
+ {
98
+ sessionID: @options[:session_id],
99
+ ProductId: @options[:product_id],
100
+ Quantity: quantity
101
+ }
102
+ end
103
+
104
+ def self.set_billing_details_params
105
+ {
106
+ sessionID: @options[:session_id],
107
+ BillingDetails: billing_details
108
+ }
109
+ end
110
+
111
+ def self.get_product_by_code_params
112
+ {
113
+ sessionID: @options[:session_id],
114
+ ProductCode: @options[:product_code]
115
+ }
116
+ end
117
+
76
118
  def self.merchant_code
77
119
  Avangate::Base.merchant_code
78
120
  end
@@ -20,4 +20,5 @@ module Avangate
20
20
  class MissingLastName < AvangateError; end
21
21
  class MissingPostalCode < AvangateError; end
22
22
  class MissingState < AvangateError; end
23
+ class MissingProductCode < AvangateError; end
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module Avangate
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avangate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2015-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler