Module: Bygpay::Utils

Included in:
Deposits, Withdrawals
Defined in:
lib/bygpay/utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def amount
  @amount
end

#responseObject

Returns the value of attribute response.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def response
  @response
end

#response_textObject

Returns the value of attribute response_text.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def response_text
  @response_text
end

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def result
  @result
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def status
  @status
end

#transaction_idObject

Returns the value of attribute transaction_id.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def transaction_id
  @transaction_id
end

#uuidObject

Returns the value of attribute uuid.



5
6
7
# File 'lib/bygpay/utils.rb', line 5

def uuid
  @uuid
end

Instance Method Details

#card_deposit_endpointObject

Mobile Deposit transactions endpoint



14
15
16
# File 'lib/bygpay/utils.rb', line 14

def card_deposit_endpoint
  Bygpay.configuration.deposit_card_path
end

#deposit_status_endpointObject

Deposit transactions status check endpoint



19
20
21
# File 'lib/bygpay/utils.rb', line 19

def deposit_status_endpoint
  Bygpay.configuration.deposit_status_path
end

#get_status(endpoint, uuid) ⇒ Object

Get transaction status



42
43
44
45
46
47
# File 'lib/bygpay/utils.rb', line 42

def get_status(endpoint, uuid)
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.get("#{url}/#{uuid}")

  parse_response(result.body)
end

#http_connectObject

global Bygpay connect



62
63
64
# File 'lib/bygpay/utils.rb', line 62

def http_connect
  HTTP[Authorization: Bygpay.configuration.api_key]
end

#mobile_deposit_endpointObject

Mobile Deposit transactions endpoint



9
10
11
# File 'lib/bygpay/utils.rb', line 9

def mobile_deposit_endpoint
  Bygpay.configuration.deposit_mobile_path
end

#mobile_withdraw_endpointObject

Mobile Withdrawal transactions endpoint



24
25
26
# File 'lib/bygpay/utils.rb', line 24

def mobile_withdraw_endpoint
  Bygpay.configuration.withdraw_mobile_path
end

#parse_response(json_payload) ⇒ Object

Parse on JSON Body to BygResponse for parsing and processing



50
51
52
53
54
55
56
57
58
59
# File 'lib/bygpay/utils.rb', line 50

def parse_response(json_payload)
  @response = Bygpay::BygResponse.parse_response(json_payload)
  resp = @response.data
  @transaction_id = @response.transaction_id
  @response_text = resp.message
  @uuid = @response.uuid
  @amount = @response.amount
  @status = @response.transaction_status
  @result = @response.request_successful?
end

#post(endpoint, payload = {}) ⇒ Object

Post payload



34
35
36
37
38
39
# File 'lib/bygpay/utils.rb', line 34

def post(endpoint, payload = {})
  url = "#{Bygpay.configuration.base_url}#{endpoint}"
  result = http_connect.post(url, json: payload)

  parse_response(result.body)
end

#withdraw_status_endpointObject

Withdraw transactions status check endpoint



29
30
31
# File 'lib/bygpay/utils.rb', line 29

def withdraw_status_endpoint
  Bygpay.configuration.withdraw_status_path
end