Class: Amax

Inherits:
Base show all
Defined in:
lib/globe_connect/amax.rb

Constant Summary collapse

AMAX_URL =
'https://devapi.globelabs.com.ph/rewards/v1/transactions/send'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#send_get_request, #send_post_request

Constructor Details

#initialize(app_id, app_secret) ⇒ Object

Starts up whenever the class is being called

Parameters:

  • app_id
  • app_secret


12
13
14
15
# File 'lib/globe_connect/amax.rb', line 12

def initialize(app_id, app_secret)
  @app_id     = app_id
  @app_secret = app_secret
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



5
6
7
# File 'lib/globe_connect/amax.rb', line 5

def app_id
  @app_id
end

#app_secretObject

Returns the value of attribute app_secret.



5
6
7
# File 'lib/globe_connect/amax.rb', line 5

def app_secret
  @app_secret
end

Instance Method Details

#send_reward_request(address, promo, rewards_token) ⇒ Object

Sends reward details to the given address

Parameters:

  • address
  • promo
  • rewards_token

Returns:

  • json



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/globe_connect/amax.rb', line 23

def send_reward_request(address, promo, rewards_token)
  # set the request url
  url = AMAX_URL

  # set the payload
  payload = {
    "outboundRewardRequest" => {
      "app_id"        => @app_id,
      "app_secret"    => @app_secret,
      "rewards_token" => rewards_token,
      "address"       => address,
      "promo"         => promo
    }
  }

  # convert to JSON
  payload = JSON.generate(payload)

  # send post request
  response = send_post_request(url, payload)

  return JSON.parse(response)
end