Class: OnlinePaymentPlatform::Client::Merchant
- Inherits:
-
Object
- Object
- OnlinePaymentPlatform::Client::Merchant
show all
- Extended by:
- Methods
- Defined in:
- lib/online_payment_platform/client/merchant.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Methods
assert_one_of!, assert_required_keys!, fetch, generate_uri, post
Constructor Details
#initialize(opts = {}) ⇒ Merchant
Returns a new instance of Merchant.
10
11
12
13
14
|
# File 'lib/online_payment_platform/client/merchant.rb', line 10
def initialize(opts = {})
@features = opts
@uid = @features['uid']
@transactions = Transaction.new @uid
end
|
Instance Attribute Details
#features ⇒ Object
Returns the value of attribute features.
6
7
8
|
# File 'lib/online_payment_platform/client/merchant.rb', line 6
def features
@features
end
|
#transactions ⇒ Object
Returns the value of attribute transactions.
6
7
8
|
# File 'lib/online_payment_platform/client/merchant.rb', line 6
def transactions
@transactions
end
|
#uid ⇒ Object
Returns the value of attribute uid.
6
7
8
|
# File 'lib/online_payment_platform/client/merchant.rb', line 6
def uid
@uid
end
|
Class Method Details
.create(opts = {}) ⇒ Object
45
46
47
48
|
# File 'lib/online_payment_platform/client/merchant.rb', line 45
def self.create(opts = {})
assert_required_keys!(opts, :country, :emailaddress, :notify_url, :phone)
Merchant.new post(generate_uri(:merchants), opts)
end
|
.find(uid) ⇒ Object
50
51
52
53
|
# File 'lib/online_payment_platform/client/merchant.rb', line 50
def self.find(uid)
response = fetch generate_uri(:merchants, uid)
Merchant.new response
end
|
.find_or_create(opts = {}) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/online_payment_platform/client/merchant.rb', line 38
def self.find_or_create(opts = {})
assert_required_keys!(opts, :country, :emailaddress, :notify_url, :phone)
response = fetch(generate_uri(:merchants) + "?filter[0][name]=emailaddress&filter=[0][operand]=eq&filter[0][value]=#{opts[:emailaddress]}")
byebug
end
|
Instance Method Details
#delete ⇒ Object
23
24
25
|
# File 'lib/online_payment_platform/client/merchant.rb', line 23
def delete
update(status: :terminated)
end
|
#migrate(opts = {}) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/online_payment_platform/client/merchant.rb', line 31
def migrate(opts = {})
parent = self.class
parent.assert_required_keys!(opts, :coc_nr, :country)
response = parent.post parent.generate_uri(:merchants, uid, :migrate), opts
Merchant.new response
end
|
#suspend ⇒ Object
27
28
29
|
# File 'lib/online_payment_platform/client/merchant.rb', line 27
def suspend
update(status: :suspended)
end
|
#update(opts = {}) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/online_payment_platform/client/merchant.rb', line 16
def update(opts = {})
parent = self.class
parent.assert_one_of!(opts, :notify_url, :return_url, :metadata, :status)
response = parent.post parent.generate_uri(:merchants, uid), opts
Merchant.new response
end
|