Class: RubyPsigate::AccountManagerApi

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/ruby_psigate/account_manager_api.rb

Constant Summary collapse

TEST_URL =
'https://dev.psigate.com:8645/Messenger/AMMessenger'
LIVE_URL =

TODO

nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#requires!

Constructor Details

#initialize(options = {}) ⇒ AccountManagerApi

Returns a new instance of AccountManagerApi.



12
13
14
15
16
# File 'lib/ruby_psigate/account_manager_api.rb', line 12

def initialize(options = {})
  requires!(options, :cid, :login, :password)
  @options = options
  @live_url = @options[:live_url]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



9
10
11
# File 'lib/ruby_psigate/account_manager_api.rb', line 9

def action
  @action
end

#testObject

Returns the value of attribute test.



10
11
12
# File 'lib/ruby_psigate/account_manager_api.rb', line 10

def test
  @test
end

Instance Method Details

#charge(options = {}) ⇒ Object



97
98
99
# File 'lib/ruby_psigate/account_manager_api.rb', line 97

def charge(options = {})

end

#disable(options = {}) ⇒ Object



93
94
95
# File 'lib/ruby_psigate/account_manager_api.rb', line 93

def disable(options = {})
  @action = "AMA09"
end

#enable(options = {}) ⇒ Object



89
90
91
# File 'lib/ruby_psigate/account_manager_api.rb', line 89

def enable(options = {})
  @action = "AMA08"
end

#register(options = {}) ⇒ Object

Registers a new account

Options (* asterisk denotes required)

> :name*

> :company

> :address1*

> :address2

> :city*

> :province*

> :postal_code*

> :country*

> :phone*

> :fax

> :email*

> :comments

> :card_holder*

> :card_number*

> :card_exp_month*

> :card_exp_year*



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ruby_psigate/account_manager_api.rb', line 42

def register(options = {})
  requires!(options, 
    :name, 
    :address1, 
    :city, 
    :province, 
    :postal_code, 
    :country, 
    :phone, 
    :email, 
    :card_holder, 
    :card_number, 
    :card_exp_month, 
    :card_exp_year
  )
  @register_options = options
  @action = "AMA01"
end

#retrieve_summary(options = {}) ⇒ Object

Retrieves a summary of a registered account



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ruby_psigate/account_manager_api.rb', line 67

def retrieve_summary(options = {})
  requires!(options, :account_id)
  @options.update(options)
  @action = "AMA00"
  
  @params = {
    :Request => {
      :CID        => @options[:cid],
      :UserID     => @options[:login],
      :Password   => @options[:password],
      :Action     => @action,
      :Condition  => {
        :AccountID  => @options[:account_id]
      }
    }
  }
  
  @data         = data_to_be_posted(@params)
  raw_response  = post_to_server(@data)
  response      = Response.new(successful?(raw_response), message_from(raw_response), raw_response, :test => test?)
end

#test?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ruby_psigate/account_manager_api.rb', line 18

def test?
  @live_url.blank?
end

#update(options = {}) ⇒ Object

Updates an already registered account



62
63
64
# File 'lib/ruby_psigate/account_manager_api.rb', line 62

def update(options = {})
  @action = "AMA02"
end