Class: BriApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ BriApi

Returns a new instance of BriApi.



10
11
12
13
14
15
16
# File 'lib/bri_api.rb', line 10

def initialize(params)
  @url = 'https://sandbox.partner.api.bri.co.id'
  @get_url = 'https://partner.api.bri.co.id'

  @ID_KEY = params[:id_key]
  @SECRET_KEY = params[:secret_key]
end

Instance Attribute Details

#fullpathObject

Returns the value of attribute fullpath.



6
7
8
# File 'lib/bri_api.rb', line 6

def fullpath
  @fullpath
end

#signatureObject

Returns the value of attribute signature.



6
7
8
# File 'lib/bri_api.rb', line 6

def signature
  @signature
end

#timestampObject

Returns the value of attribute timestamp.



6
7
8
# File 'lib/bri_api.rb', line 6

def timestamp
  @timestamp
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/bri_api.rb', line 6

def token
  @token
end

Instance Method Details

#create_briva_endpoint(params) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bri_api.rb', line 34

def create_briva_endpoint(params)
  params[:description] ||= ""
  params[:expired_days] ||= 1
  data = {
  	"institutionCode": params[:institution_code],
   "brivaNo": params[:briva_no],
   "custCode": params[:cust_code],
   "nama": params[:name],
   "amount": params[:amount],
   "keterangan": params[:description],
   "expiredDate": (Date.today + params[:expired_days]).strftime("%F %H:%M:%S")
  }
  response = post_request('/sandbox/v1/briva',data)
  JSON.parse response.body
end

#get_account_info(params) ⇒ Object



20
21
22
23
24
25
# File 'lib/bri_api.rb', line 20

def (params)
  params[:url] ||= @url
  path = '/sandbox/v2/inquiry/' + params[:account_number]
  response = get_request(path, params)
  JSON.parse(response.body)['Data']
end

#get_briva_status(params) ⇒ Object



53
54
55
56
57
# File 'lib/bri_api.rb', line 53

def get_briva_status(params)
  params[:url] ||= @url
  response = get_request('/v1/briva/' + params[:institution_code] + '/' + params[:briva_no] + '/' + params[:cust_code], params)
  JSON.parse response.body
end