Skip to content

Commit 0ef201b

Browse files
Merge pull request #14 from mekari-engineering/KRED-1798
KRED-1798 update lib to use partner api and able to log request respo…
2 parents 29f82a2 + c128e50 commit 0ef201b

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/midtrans_api.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module MidtransApi
44
API_PRODUCTION_URL = 'https://api.midtrans.com'
55
API_SANDBOX_URL = 'https://api.sandbox.midtrans.com'
6+
API_PARTNER_URL = 'https://partner-api.midtrans.com'
67

78
class << self
89
attr_accessor :configuration

lib/midtrans_api/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def initialize(options = {})
5555

5656
logger = find_logger(options[:logger])
5757
if logger
58-
connection.response :logger, logger, { headers: false, bodies: true } do |log|
58+
connection.response :logger, logger, { headers: @config.log_headers, bodies: true } do |log|
5959
filtered_logs = options[:filtered_logs]
6060
if filtered_logs.respond_to?(:each)
6161
filtered_logs.each do |filter|

lib/midtrans_api/configure.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class Configure
77
:notification_url,
88
:sandbox_mode,
99
:logger,
10-
:timeout
10+
:timeout,
11+
:log_headers
1112
attr_reader :api_version
1213

1314
def initialize(options = {})
@@ -17,9 +18,13 @@ def initialize(options = {})
1718
@sandbox_mode = options[:sandbox] || false
1819
@timeout = options[:timeout] || 60
1920
@api_version = options[:api_version] || :v2
21+
@use_partner_api = options[:use_partner_api] || false
22+
@log_headers = options[:log_headers] || false
2023
end
2124

2225
def api_url
26+
return MidtransApi::API_PARTNER_URL if @use_partner_api
27+
2328
return MidtransApi::API_SANDBOX_URL if sandbox_mode
2429

2530
MidtransApi::API_PRODUCTION_URL

0 commit comments

Comments
 (0)