Class: EasyPing::Charge
Constant Summary
collapse
- REQUIRED =
[
'order_no', 'app[id]', 'channel', 'amount', 'client_ip', 'currency',
'subject', 'body'
]
Constants inherited
from Action
Action::CHANNELS
Instance Attribute Summary
Attributes inherited from Action
#client, #config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Action
#from_notification
Methods included from Utils
#indifferent_hash, #indifferent_params
Constructor Details
#initialize(config) ⇒ Charge
Returns a new instance of Charge.
140
141
142
143
|
# File 'lib/easy_ping/action.rb', line 140
def initialize(config)
super(config)
@settings = config.to_options.merge default_charge_options
end
|
Class Method Details
.create(*args) ⇒ Object
136
137
138
|
# File 'lib/easy_ping/action.rb', line 136
def self.create(*args)
new(EasyPing::Base.config).charge(*args)
end
|
Instance Method Details
#all(params = {}) ⇒ Object
165
166
167
168
169
170
171
172
173
|
# File 'lib/easy_ping/action.rb', line 165
def all(params={})
params = indifferent_hash params
params = compile params
raw_response = client.run :get, api_endpoint, params
EasyPing::Model::Wrapper.parse! raw_response, config
end
|
#charge(*args) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/easy_ping/action.rb', line 145
def charge(*args)
params = indifferent_params(args, 'order_number', 'amount', 'subject', 'body')
params = @settings.merge params
params = compile params
verify! params, charge_requires
raw_response = client.run(:post, api_endpoint, params)
EasyPing::Model::Wrapper.parse! raw_response, config
end
|
#find(*args) ⇒ Object
158
159
160
161
162
163
|
# File 'lib/easy_ping/action.rb', line 158
def find(*args)
params = indifferent_params(args, 'charge_id')
raw_response = client.run :get, "#{api_endpoint}/#{params['charge_id']}"
EasyPing::Model::Wrapper.parse! raw_response, config
end
|