Class: Avangate::SOAP

Inherits:
Object
  • Object
show all
Defined in:
lib/avangate.rb

Class Method Summary collapse

Class Method Details

.add_product(options = {}) ⇒ Object

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/avangate.rb', line 21

def self.add_product(options={})
  raise MissingSessionId, "missing param session_id" unless options[:session_id].presence
  raise MissingProductId, "missing param product_id" unless options[:product_id].presence
  quantity = options[:quantity].presence ? options[:quantity] : 1
  params = {
      sessionID: options[:session_id],
      ProductId: options[:product_id],
      Quantity: quantity

  }
  response = client.call :add_product, message: params
  return response.body.first[1].first[1]
end

.loginObject



12
13
14
15
16
17
18
19
# File 'lib/avangate.rb', line 12

def self.
  begin
    response = client.call :login, message: 
    return response.body.first[1].first[1]
  rescue Savon::SOAPFault => e
    return false
  end
end

.set_billing_details(options = {}) ⇒ Object

Raises:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/avangate.rb', line 35

def self.set_billing_details(options={})
  raise MissingSessionId, "missing param session_id" unless options[:session_id].presence
  raise MissingAddress, "missing param address" unless options[:address].presence
  raise MissingCity, "missing param city" unless options[:city].presence
  raise MissingCountry, "missing param country" unless options[:country].presence
  raise MissingEmail, "missing param email" unless options[:email].presence
  raise MissingFirstName, "missing param first_name" unless options[:first_name].presence
  raise MissingLastName, "missing param last_name" unless options[:last_name].presence
  raise MissingPostalCode, "missing param postal_code" unless options[:postal_code].presence
  raise MissingState, "missing param state" unless options[:state].presence or !STATE_REQUIRED_COUNTRIES.include? options[:country]
  billing_details = {
      Address: options[:address],
      City: options[:city],
      Country: options[:country],
      Email: options[:email],
      FirstName: options[:first_name],
      LastName: options[:last_name],
      PostalCode: options[:postal_code],
      State: options[:state]
  }
  params = {
      sessionID: options[:session_id],
      BillingDetails: billing_details
  }
  response = client.call :set_billing_details, message: params
  return response.body.first[1].first[1]
end