lib/payment/manager/client.rb in payment-manager-client-0.2.0 vs lib/payment/manager/client.rb in payment-manager-client-0.3.0
- old
+ new
@@ -1,9 +1,12 @@
-require "payment/manager/client/version"
-require "payment/manager/request"
-require "payment/manager/config"
-require "json"
+# frozen_string_literal: true
+require 'payment/manager/client/version'
+require 'payment/manager/request'
+require 'payment/manager/config'
+require 'payment/manager/plan_parser'
+require 'payment/manager/plan'
+require 'json'
module Payment
module Manager
module Client
class << self
@@ -19,25 +22,25 @@
client_id: config.client_id,
client_secret: config.client_secret,
plan_id: plan_id,
resource_id: resource_id
}
- response = Payment::Manager::Request.get(config.api_url + '/api/checkout', params)
+ response = Payment::Manager::Request.get_from_api('/api/checkout', params)
JSON.parse(response.body)['url']
end
def plans
params = {
client_id: config.client_id,
- client_secret: config.client_secret,
+ client_secret: config.client_secret
}
- response = Payment::Manager::Request.get(config.api_url + '/api/plans', params)
- JSON.parse(response.body)
+ response = Payment::Manager::Request.get_from_api('/api/plans', params)
+ PlanParser.new(response.body).plans
end
def valid_token?(token)
- response = Payment::Manager::Request.get(config.api_url + "/api/tokens/validate/#{config.client_id}/#{token}", {})
+ response = Payment::Manager::Request.get_from_api("/api/tokens/validate/#{config.client_id}/#{token}", {})
JSON.parse(response.body)['valid']
end
end
end
end