Class: MobicomCandy::Client

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

Overview

API Client Wrapper

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.

Parameters:

  • token (String)


8
9
10
11
# File 'lib/mobicom_candy/client.rb', line 8

def initialize(token)
  @token = token
  @last_sent = nil
end

Instance Method Details

#customer(customer_id, system) ⇒ MobicomCandy::Entity

Parameters:

  • customer_id (String)
  • system (String)

Returns:



23
24
25
# File 'lib/mobicom_candy/client.rb', line 23

def customer(customer_id, system)
  post('customer', customer: customer_id, 'customer.system' => system)
end

#reward(customer_id, system, amount, description) ⇒ MobicomCandy::Entity

Parameters:

  • customer_id (String)
  • system (String)
  • amount (Decimal)
  • description (String)

Returns:



32
33
34
35
36
37
38
39
40
41
# File 'lib/mobicom_candy/client.rb', line 32

def reward(customer_id, system, amount, description)
  post('reward',
       'customer' => {
         value: customer_id,
         system: system
       },
       amount: amount,
       description: description
  )
end

#sell(customer_id, system, amount, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil) ⇒ MobicomCandy::Entity

Parameters:

  • customer_id (String)
  • system (String)
  • amount (Decimal)
  • description (String) (defaults to: nil)
  • sms_prefix (String) (defaults to: nil)
  • sms_suffix (String) (defaults to: nil)
  • product (String) (defaults to: nil)
  • product_type (String) (defaults to: nil)

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/mobicom_candy/client.rb', line 52

def sell(customer_id, system, amount, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil)
  post('sell',
       'customer' => {
         value: customer_id,
         system: system
       },
       amount: amount,
       description: description,
       smsPrefix: sms_prefix,
       smsSuffix: sms_suffix,
       product: product,
       productType: product_type
  )
end

#sell_card(card_id, system, amount, pin, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil) ⇒ MobicomCandy::Entity

Parameters:

  • card_id (String)
  • system (String)
  • amount (Decimal)
  • pin (String)
  • description (String) (defaults to: nil)
  • sms_prefix (String) (defaults to: nil)
  • sms_suffix (String) (defaults to: nil)
  • product (String) (defaults to: nil)
  • product_type (String) (defaults to: nil)

Returns:



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/mobicom_candy/client.rb', line 89

def sell_card(card_id, system, amount, pin, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil)
  post('sellcard',
       'customer' => {
         value: card_id,
         system: system
       },
       amount: amount,
       pin: pin,
       description: description,
       smsPrefix: sms_prefix,
       smsSuffix: sms_suffix,
       product: product,
       productType: product_type
  )
end

#sell_confirm(customer_id, system, amount, tancode) ⇒ MobicomCandy::Entity

Parameters:

  • customer_id (String)
  • system (String)
  • amount (Decimal)
  • tancode (String)

Returns:



72
73
74
75
76
77
# File 'lib/mobicom_candy/client.rb', line 72

def sell_confirm(customer_id, system, amount, tancode)
  post('sellconfirm', 'customer' => {
    value: customer_id,
    system: system
  }, amount: amount, tancode: tancode)
end

#transaction(limit = 10, offset = 0) ⇒ MobicomCandy::Entity

Parameters:

  • limit (Integer) (defaults to: 10)
  • offset (Integer) (defaults to: 0)

Returns:



16
17
18
# File 'lib/mobicom_candy/client.rb', line 16

def transaction(limit = 10, offset = 0)
  get('transaction', limit: limit, offset: offset)
end