Class: Maventa::Client
- Inherits:
-
Object
- Object
- Maventa::Client
- Defined in:
- lib/maventa/client.rb
Instance Method Summary collapse
- #analysis ⇒ Object
- #authorize(grant_type: "client_credentials", scope: "global company") ⇒ Object
- #companies ⇒ Object
- #company ⇒ Object
- #definitions ⇒ Object
- #documents ⇒ Object
- #fi_bank_messages ⇒ Object
- #files ⇒ Object
-
#initialize(client_id: nil, client_secret: nil, vendor_api_key: nil, mode: :production) ⇒ Client
constructor
A new instance of Client.
- #invoices ⇒ Object
- #jwk ⇒ Object
- #lookup ⇒ Object
- #oauth2 ⇒ Object
- #odp ⇒ Object
- #operator ⇒ Object
- #partner ⇒ Object
- #services ⇒ Object
- #status ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(client_id: nil, client_secret: nil, vendor_api_key: nil, mode: :production) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/maventa/client.rb', line 3 def initialize(client_id: nil, client_secret: nil, vendor_api_key: nil, mode: :production) @client_id = client_id || Maventa::config[:client_id] @client_secret = client_secret || Maventa::config[:client_secret] @vendor_api_key = vendor_api_key || Maventa::config[:vendor_api_key] @mode = mode @access_token = nil @connection = Faraday.new( url: Maventa::API_URL[mode], headers: { "Content-Type" => "application/x-www-form-urlencoded" } ) end |
Instance Method Details
#analysis ⇒ Object
30 31 32 |
# File 'lib/maventa/client.rb', line 30 def analysis @analysis ||= Analysis.new(@connection, @access_token) end |
#authorize(grant_type: "client_credentials", scope: "global company") ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/maventa/client.rb', line 18 def (grant_type: "client_credentials", scope: "global company") if @access_token&.valid? @access_token else @access_token = oauth2.token(grant_type:, scope:) end end |
#companies ⇒ Object
34 35 36 |
# File 'lib/maventa/client.rb', line 34 def companies @companies ||= Companies.new(@connection, @access_token) end |
#company ⇒ Object
38 39 40 |
# File 'lib/maventa/client.rb', line 38 def company @company ||= Company.new(@connection, @access_token) end |
#definitions ⇒ Object
42 43 44 |
# File 'lib/maventa/client.rb', line 42 def definitions @definitions ||= Definitions.new(@connection, @access_token) end |
#documents ⇒ Object
46 47 48 |
# File 'lib/maventa/client.rb', line 46 def documents @documents ||= Documents.new(@connection, @access_token) end |
#fi_bank_messages ⇒ Object
50 51 52 |
# File 'lib/maventa/client.rb', line 50 def @fi_bank_messages ||= FiBankMessages.new(@connection, @access_token) end |
#files ⇒ Object
54 55 56 |
# File 'lib/maventa/client.rb', line 54 def files @files ||= Files.new(@connection, @access_token) end |
#invoices ⇒ Object
58 59 60 |
# File 'lib/maventa/client.rb', line 58 def invoices @invoices ||= Invoices.new(@connection, @access_token) end |
#jwk ⇒ Object
62 63 64 |
# File 'lib/maventa/client.rb', line 62 def jwk @jwk ||= Jwk.new(@connection, @access_token) end |
#lookup ⇒ Object
66 67 68 |
# File 'lib/maventa/client.rb', line 66 def lookup @lookup ||= Lookup.new(@connection, @access_token) end |
#oauth2 ⇒ Object
26 27 28 |
# File 'lib/maventa/client.rb', line 26 def oauth2 @oauth2 ||= OAuth2.new(@connection, client_id: @client_id, client_secret: @client_secret, vendor_api_key: @vendor_api_key) end |
#odp ⇒ Object
70 71 72 |
# File 'lib/maventa/client.rb', line 70 def odp @odp ||= Odp.new(@connection, @access_token) end |
#operator ⇒ Object
74 75 76 |
# File 'lib/maventa/client.rb', line 74 def operator @operator ||= Operator.new(@connection, @access_token) end |
#partner ⇒ Object
78 79 80 |
# File 'lib/maventa/client.rb', line 78 def partner @partner ||= Partner.new(@connection, @access_token) end |
#services ⇒ Object
82 83 84 |
# File 'lib/maventa/client.rb', line 82 def services @services ||= Services.new(@connection, @access_token) end |