Class: MasspayRubySdk::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, faraday_options = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

Options Hash (options):

  • :basic_auth (String)

    A basic auth string of the form “username:password” (default: nil)

  • :bearer_auth (String)

    A bearer auth token (default: nil)

  • :url (String)

    The base URL for the API (default: nil, which will use the production API)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/masspay_ruby_sdk/client.rb', line 21

def initialize(options = {}, faraday_options = {})

  faraday_options[:url] ||= options[:url] || "https://api.masspay.io/v1.0.0"

  @client = Faraday.new(faraday_options) do |builder|
    builder.request :json
    builder.response :json, parser_options: { object_class: OpenStruct }
    builder.adapter Faraday.default_adapter

    builder.headers[USER_AGENT_HEADER_NAME] = USER_AGENT

    if options[:basic_auth] || options[:bearer_auth]
      if(!options[:bearer_auth].nil?)
        builder.request :authorization, 'Bearer', options[:bearer_auth]
      elsif !options[:basic_auth]
        builder.request :authorization, :basic, options[:basic_auth].split(":").first, options[:basic_auth].split(":").last
      end
    end

  end
end

Instance Method Details

#account_serviceObject



43
44
45
# File 'lib/masspay_ruby_sdk/client.rb', line 43

def 
  MasspayRubySdk::AccountService.new(@client)
end

#attribute_serviceObject



47
48
49
# File 'lib/masspay_ruby_sdk/client.rb', line 47

def attribute_service
  MasspayRubySdk::AttributeService.new(@client)
end

#card_serviceObject



51
52
53
# File 'lib/masspay_ruby_sdk/client.rb', line 51

def card_service
  MasspayRubySdk::CardService.new(@client)
end

#catalog_serviceObject



55
56
57
# File 'lib/masspay_ruby_sdk/client.rb', line 55

def catalog_service
  MasspayRubySdk::CatalogService.new(@client)
end

#kyc_serviceObject



59
60
61
# File 'lib/masspay_ruby_sdk/client.rb', line 59

def kyc_service
  MasspayRubySdk::KycService.new(@client)
end

#load_serviceObject



63
64
65
# File 'lib/masspay_ruby_sdk/client.rb', line 63

def load_service
  MasspayRubySdk::LoadService.new(@client)
end

#payout_serviceObject



67
68
69
# File 'lib/masspay_ruby_sdk/client.rb', line 67

def payout_service
  MasspayRubySdk::PayoutService.new(@client)
end

#spend_back_serviceObject



71
72
73
# File 'lib/masspay_ruby_sdk/client.rb', line 71

def spend_back_service
  MasspayRubySdk::SpendBackService.new(@client)
end

#subaccount_serviceObject



75
76
77
# File 'lib/masspay_ruby_sdk/client.rb', line 75

def subaccount_service
  MasspayRubySdk::SubaccountService.new(@client)
end

#tax_serviceObject



79
80
81
# File 'lib/masspay_ruby_sdk/client.rb', line 79

def tax_service
  MasspayRubySdk::TaxService.new(@client)
end

#user_serviceObject



83
84
85
# File 'lib/masspay_ruby_sdk/client.rb', line 83

def user_service
  MasspayRubySdk::UserService.new(@client)
end

#wallet_serviceObject



87
88
89
# File 'lib/masspay_ruby_sdk/client.rb', line 87

def wallet_service
  MasspayRubySdk::WalletService.new(@client)
end