Class: PapierkramApi::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/papierkram_api/client.rb

Overview

The Client class is the main entry point for the Papierkram API Client.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subdomain = nil, api_key = nil) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
# File 'lib/papierkram_api/client.rb', line 15

def initialize(subdomain = nil, api_key = nil)
  @subdomain = subdomain || ENV.fetch('PAPIERKRAM_API_SUBDOMAIN', nil)
  @api_key = api_key || ENV.fetch('PAPIERKRAM_API_KEY', nil)
  @base_url = base_url_env
  @remaining_quota = nil
  build_client!
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/papierkram_api/client.rb', line 6

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



6
7
8
# File 'lib/papierkram_api/client.rb', line 6

def base_url
  @base_url
end

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/papierkram_api/client.rb', line 6

def client
  @client
end

#remaining_quotaObject

Returns the value of attribute remaining_quota.



6
7
8
# File 'lib/papierkram_api/client.rb', line 6

def remaining_quota
  @remaining_quota
end

#subdomainObject

Returns the value of attribute subdomain.



6
7
8
# File 'lib/papierkram_api/client.rb', line 6

def subdomain
  @subdomain
end

Instance Method Details

#banking_bank_connectionsObject



40
41
42
43
# File 'lib/papierkram_api/client.rb', line 40

def banking_bank_connections
  @banking_bank_connections ||=
    PapierkramApi::V1::Endpoints::Banking::BankConnections.new(@client)
end

#banking_transactionsObject



45
46
47
48
# File 'lib/papierkram_api/client.rb', line 45

def banking_transactions
  @banking_transactions ||=
    PapierkramApi::V1::Endpoints::Banking::Transactions.new(@client)
end

#build_client!Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/papierkram_api/client.rb', line 23

def build_client!
  @client = Faraday.new(url: @base_url) do |config|
    config.request :authorization, 'Bearer', @api_key
    config.request :multipart
    config.request :json
    config.response :json

    config.adapter :httpx
    yield(config) if block_given?
  end
end

#business_intelligenceObject



35
36
37
38
# File 'lib/papierkram_api/client.rb', line 35

def business_intelligence
  @business_intelligence ||=
    PapierkramApi::V1::BusinessIntelligence::Base.new
end

#contact_companiesObject



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

def contact_companies
  @contact_companies ||=
    PapierkramApi::V1::Endpoints::Contact::Companies.new(@client)
end

#contact_companies_personsObject



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

def contact_companies_persons
  @contact_companies_persons ||=
    PapierkramApi::V1::Endpoints::Contact::CompaniesPersons.new(@client)
end

#expense_vouchersObject



60
61
62
63
# File 'lib/papierkram_api/client.rb', line 60

def expense_vouchers
  @expense_vouchers ||=
    PapierkramApi::V1::Endpoints::Expense::Vouchers.new(@client)
end

#income_estimatesObject



65
66
67
68
# File 'lib/papierkram_api/client.rb', line 65

def income_estimates
  @income_estimates ||=
    PapierkramApi::V1::Endpoints::Income::Estimates.new(@client)
end

#income_invoicesObject



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

def income_invoices
  @income_invoices ||=
    PapierkramApi::V1::Endpoints::Income::Invoices.new(@client)
end

#income_payment_termsObject



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

def income_payment_terms
  @income_payment_terms ||=
    PapierkramApi::V1::Endpoints::Income::PaymentTerms.new(@client)
end

#income_propositionsObject



80
81
82
83
# File 'lib/papierkram_api/client.rb', line 80

def income_propositions
  @income_propositions ||=
    PapierkramApi::V1::Endpoints::Income::Propositions.new(@client)
end

#infoObject



85
86
87
88
# File 'lib/papierkram_api/client.rb', line 85

def info
  @info ||=
    PapierkramApi::V1::Endpoints::Info.new(@client)
end

#projectsObject



90
91
92
93
# File 'lib/papierkram_api/client.rb', line 90

def projects
  @projects ||=
    PapierkramApi::V1::Endpoints::Projects.new(@client)
end

#tracker_tasksObject



95
96
97
98
# File 'lib/papierkram_api/client.rb', line 95

def tracker_tasks
  @tracker_tasks ||=
    PapierkramApi::V1::Endpoints::Tracker::Tasks.new(@client)
end

#tracker_time_entriesObject



100
101
102
103
# File 'lib/papierkram_api/client.rb', line 100

def tracker_time_entries
  @tracker_time_entries ||=
    PapierkramApi::V1::Endpoints::Tracker::TimeEntries.new(@client)
end