Skip to content

Commit 16c3139

Browse files
author
Tjandra Darmo
authored
Merge pull request #53 from mekari-engineering/KRED-2019-instrumentation
KRED-2019 setup instrumentation on Faraday init
2 parents 589c0af + 9e07005 commit 16c3139

12 files changed

Lines changed: 28 additions & 7 deletions

File tree

lib/xendit_api/api/balance.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Balance < XenditApi::Api::Base
1111
def get(account_type = nil, currency = CURRENCY, headers = {})
1212
account_type = account_type.nil? ? CASH : account_type
1313
get_path = "#{PATH}?account_type=#{account_type}&currency=#{currency}"
14+
headers = headers.merge({ 'Path-Group' => PATH })
1415
response = @client.get(get_path, nil, headers)
1516
XenditApi::Model::Balance.new(response.merge(payload: response.to_json))
1617
end

lib/xendit_api/api/credit_card.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class CreditCard < XenditApi::Api::Base
88
PATH = '/credit_card_charges'.freeze
99

1010
def charge(params, headers = {})
11+
headers = headers.merge({ 'Path-Group' => PATH })
1112
response = client.post(PATH, params, headers)
1213
credit_card_params = permitted_credit_card_params(response)
1314
XenditApi::Model::CreditCard.new(credit_card_params)
@@ -16,6 +17,7 @@ def charge(params, headers = {})
1617
def find(id, headers = {}, id_type = nil)
1718
find_path = "#{PATH}/#{id}"
1819
find_path = "#{find_path}?id_type=#{id_type}" unless id_type.nil?
20+
headers = headers.merge({ 'Path-Group' => "#{PATH}/{id}" })
1921
response = client.get(find_path, nil, headers)
2022
credit_card_params = permitted_credit_card_params(response)
2123
XenditApi::Model::CreditCard.new(credit_card_params)

lib/xendit_api/api/disbursement.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Disbursement < XenditApi::Api::Base
77
PATH = '/disbursements'.freeze
88

99
def create(params, headers = {})
10+
headers = headers.merge({ 'Path-Group' => PATH })
1011
response = client.post_response(PATH, params, headers)
1112
XenditApi::Model::Disbursement.new(response.body.merge(payload: response.body.to_json, request_id: response.headers['request-id']))
1213
end

lib/xendit_api/api/fee_rule.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class FeeRule < XenditApi::Api::Base
77
PATH = '/fee_rules'.freeze
88

99
def create(params)
10-
response = client.post(PATH, params)
10+
headers = { 'Path-Group' => PATH }
11+
response = client.post(PATH, params, headers)
1112
XenditApi::Model::FeeRule.new(response)
1213
end
1314
end

lib/xendit_api/api/qr_code.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,21 @@ class QrCode < XenditApi::Api::Base
88
PATH = '/qr_codes'.freeze
99

1010
def create(params, headers = {})
11+
headers = headers.merge({ 'Path-Group' => PATH })
1112
response = @client.post(PATH, params, headers)
1213
XenditApi::Model::QrCode.new(response.merge(payload: response.to_json))
1314
end
1415

1516
def find(external_id, headers = {})
1617
find_path = "#{PATH}/#{external_id}"
18+
headers = headers.merge({ 'Path-Group' => "#{PATH}/{external_id}" })
1719
response = @client.get(find_path, nil, headers)
1820
XenditApi::Model::QrCode.new(response.merge(payload: response.to_json))
1921
end
2022

2123
def find_payments(external_id, headers = {})
2224
find_payments_path = "#{PATH}/payments?external_id=#{external_id}"
25+
headers = headers.merge({ 'Path-Group' => "#{PATH}/payments" })
2326
response = @client.get(find_payments_path, nil, headers)
2427
response.map do |payment|
2528
XenditApi::Model::QrCodePayment.new(payment.merge(payload: payment.to_json))

lib/xendit_api/api/report.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Report < XenditApi::Api::Base
77
PATH = '/reports'.freeze
88

99
def create(params, headers = {})
10+
headers = headers.merge({ 'Path-Group' => PATH })
1011
response = client.post(PATH, params, headers)
1112
XenditApi::Model::Report.new(response)
1213
end

lib/xendit_api/api/transaction.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Transaction < XenditApi::Api::Base
88

99
def list(query_string = '', headers = {})
1010
transactions_path = query_string.to_s.empty? ? PATH : "#{PATH}?#{query_string}"
11+
headers = headers.merge({ 'Path-Group' => PATH })
1112
response = @client.get(transactions_path, nil, headers)
1213

1314
data = response['data'].map do |transaction|

lib/xendit_api/api/transfer.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ class Transfer < XenditApi::Api::Base
77
PATH = '/transfers'.freeze
88

99
def create(params)
10-
response = client.post(PATH, params)
10+
headers = { 'Path-Group' => PATH }
11+
response = client.post(PATH, params, headers)
1112
XenditApi::Model::Transfer.new(response)
1213
end
1314

1415
def find_by_reference(reference)
15-
response = client.get("#{PATH}/reference=#{reference}")
16+
headers = { 'Path-Group' => "#{PATH}/reference" }
17+
response = client.get("#{PATH}/reference=#{reference}", nil, headers)
1618
XenditApi::Model::Transfer.new(response)
1719
end
1820
end

lib/xendit_api/api/v2/account.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class Account < XenditApi::Api::Base
88
PATH = '/v2/accounts'.freeze
99

1010
def create(params)
11-
response = client.post(PATH, params)
11+
headers = { 'Path-Group' => "#{PATH}/{id}" }
12+
response = client.post(PATH, params, headers)
1213

1314
XenditApi::Model::V2::Account.new(response)
1415
end

lib/xendit_api/api/v2/invoice.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,26 @@ class Invoice < XenditApi::Api::Base
88
PATH = '/v2/invoices'.freeze
99

1010
def get(invoice_id)
11-
response = client.get("#{PATH}/#{invoice_id}")
11+
headers = { 'Path-Group' => "#{PATH}/{invoice_id}" }
12+
response = client.get("#{PATH}/#{invoice_id}", nil, headers)
1213

1314
XenditApi::Model::V2::Invoice.new(response)
1415
end
1516

1617
def get_by_external_id(external_id)
18+
headers = { 'Path-Group' => PATH }
1719
response = client.get(PATH, {
1820
external_id: external_id
19-
})
21+
}, headers)
2022

2123
response.map do |invoice|
2224
XenditApi::Model::V2::Invoice.new(invoice)
2325
end
2426
end
2527

2628
def post(params:)
27-
response = client.post(PATH, params)
29+
headers = { 'Path-Group' => PATH }
30+
response = client.post(PATH, params, headers)
2831

2932
XenditApi::Model::V2::Invoice.new(response)
3033
end

0 commit comments

Comments
 (0)