class BloomRemit2::Client
Public Class Methods
delete(path, headers = default_get_headers, staging: false)
click to toggle source
# File lib/bloom_remit2/client.rb, line 24 def delete(path, headers = default_get_headers, staging: false) the_url = url(path) the_url = staging_url(path) if staging HTTParty.delete(the_url, { headers: headers }) end
get(path, headers = default_get_headers, query: {}, staging: false)
click to toggle source
# File lib/bloom_remit2/client.rb, line 6 def get(path, headers = default_get_headers, query: {}, staging: false) the_url = url(path) the_url = staging_url(path) if staging HTTParty.get(the_url, { query: query, headers: headers }) end
post(path, body = {}, staging = false, headers = default_post_headers)
click to toggle source
# File lib/bloom_remit2/client.rb, line 12 def post(path, body = {}, staging = false, headers = default_post_headers) the_url = url(path) the_url = staging_url(path) if staging HTTParty.post(the_url, { body: body.to_json, headers: headers }) end
put(path, body = [], headers = default_put_headers, staging: false)
click to toggle source
# File lib/bloom_remit2/client.rb, line 18 def put(path, body = [], headers = default_put_headers, staging: false) the_url = url(path) the_url = staging_url(path) if staging HTTParty.put(the_url, { body: URI.encode_www_form(body), headers: headers }) end
Private Class Methods
api_secret_key()
click to toggle source
# File lib/bloom_remit2/client.rb, line 44 def api_secret_key BloomRemit2.configuration.api_secret_key end
base_url()
click to toggle source
# File lib/bloom_remit2/client.rb, line 32 def base_url 'https://www.bloomremit.net' end
default_get_headers()
click to toggle source
# File lib/bloom_remit2/client.rb, line 48 def default_get_headers { 'x-api-secret' => api_secret_key, 'cache-control' => 'no-cache' } end
default_post_headers()
click to toggle source
# File lib/bloom_remit2/client.rb, line 62 def default_post_headers default_get_headers.merge!( { 'content-type' => 'application/json' } ) end
default_put_headers()
click to toggle source
# File lib/bloom_remit2/client.rb, line 55 def default_put_headers { 'x-api-secret' => api_secret_key, 'content-type' => 'application/x-www-form-urlencoded' } end
staging_url(path)
click to toggle source
# File lib/bloom_remit2/client.rb, line 36 def staging_url(path) "https://staging.bloomremit.net/#{path}" end
url(path)
click to toggle source
# File lib/bloom_remit2/client.rb, line 40 def url(path) "#{base_url}/#{path}" end