Class: Pluggy::Client
- Inherits:
-
Object
- Object
- Pluggy::Client
- Defined in:
- lib/pluggy/client.rb
Overview
The entry point.
client = Pluggy::Client.new(
client_id: ENV["PLUGGY_CLIENT_ID"],
client_secret: ENV["PLUGGY_CLIENT_SECRET"]
)
client.accounts.list(item_id: item_id)
Authentication is handled for you: the apiKey is fetched lazily on the first request, cached until the expiry in its own JWT, and renewed transparently if the API rejects it mid-session.
One client holds one credential set and is safe to share across threads.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#requestor ⇒ Object
readonly
Returns the value of attribute requestor.
Instance Method Summary collapse
- #accounts ⇒ Object
-
#api_key ⇒ Object
The current apiKey, authenticating first if needed.
- #bills ⇒ Object
- #categories ⇒ Object
- #connect_tokens ⇒ Object
- #connectors ⇒ Object
-
#create_connect_token(**kwargs) ⇒ Object
The first call most integrations make.
- #delete(path, **params) ⇒ Object
-
#get(path, **params) ⇒ Object
Escape hatches for the endpoints this gem deliberately does not model (payments, smart transfers, boletos, consents, webhooks, investments, identity).
-
#initialize(client_id: nil, client_secret: nil, api_key: nil, **options) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object (also: #to_s)
- #items ⇒ Object
- #loans ⇒ Object
- #merchants ⇒ Object
- #patch(path, **body) ⇒ Object
- #post(path, **body) ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(client_id: nil, client_secret: nil, api_key: nil, **options) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pluggy/client.rb', line 20 def initialize(client_id: nil, client_secret: nil, api_key: nil, **) @config = Pluggy.config.merge( client_id: client_id, client_secret: client_secret, api_key: api_key, ** ) @config.validate! @requestor = APIRequestor.new(@config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
18 19 20 |
# File 'lib/pluggy/client.rb', line 18 def config @config end |
#requestor ⇒ Object (readonly)
Returns the value of attribute requestor.
18 19 20 |
# File 'lib/pluggy/client.rb', line 18 def requestor @requestor end |
Instance Method Details
#accounts ⇒ Object
31 |
# File 'lib/pluggy/client.rb', line 31 def accounts = @accounts ||= Services::AccountService.new(self) |
#api_key ⇒ Object
The current apiKey, authenticating first if needed. Rarely useful directly -- mostly for debugging and for the live smoke test.
46 |
# File 'lib/pluggy/client.rb', line 46 def api_key = @requestor.credentials.fetch(@requestor).to_s |
#bills ⇒ Object
33 |
# File 'lib/pluggy/client.rb', line 33 def bills = @bills ||= Services::BillService.new(self) |
#categories ⇒ Object
37 |
# File 'lib/pluggy/client.rb', line 37 def categories = @categories ||= Services::CategoryService.new(self) |
#connect_tokens ⇒ Object
39 |
# File 'lib/pluggy/client.rb', line 39 def connect_tokens = @connect_tokens ||= Services::ConnectTokenService.new(self) |
#connectors ⇒ Object
36 |
# File 'lib/pluggy/client.rb', line 36 def connectors = @connectors ||= Services::ConnectorService.new(self) |
#create_connect_token(**kwargs) ⇒ Object
The first call most integrations make.
42 |
# File 'lib/pluggy/client.rb', line 42 def create_connect_token(**kwargs) = connect_tokens.create(**kwargs) |
#delete(path, **params) ⇒ Object
54 |
# File 'lib/pluggy/client.rb', line 54 def delete(path, **params) = @requestor.request(:delete, path, params: params) |
#get(path, **params) ⇒ Object
Escape hatches for the endpoints this gem deliberately does not model (payments, smart transfers, boletos, consents, webhooks, investments, identity). Returns parsed JSON, not resource objects.
51 |
# File 'lib/pluggy/client.rb', line 51 def get(path, **params) = @requestor.request(:get, path, params: params) |
#inspect ⇒ Object Also known as: to_s
56 57 58 |
# File 'lib/pluggy/client.rb', line 56 def inspect "#<Pluggy::Client client_id=#{@config.client_id.to_s[0, 8]}... api_base=#{@config.api_base}>" end |
#items ⇒ Object
35 |
# File 'lib/pluggy/client.rb', line 35 def items = @items ||= Services::ItemService.new(self) |
#loans ⇒ Object
34 |
# File 'lib/pluggy/client.rb', line 34 def loans = @loans ||= Services::LoanService.new(self) |
#merchants ⇒ Object
38 |
# File 'lib/pluggy/client.rb', line 38 def merchants = @merchants ||= Services::MerchantService.new(self) |
#patch(path, **body) ⇒ Object
53 |
# File 'lib/pluggy/client.rb', line 53 def patch(path, **body) = @requestor.request(:patch, path, body: body) |
#post(path, **body) ⇒ Object
52 |
# File 'lib/pluggy/client.rb', line 52 def post(path, **body) = @requestor.request(:post, path, body: body) |
#transactions ⇒ Object
32 |
# File 'lib/pluggy/client.rb', line 32 def transactions = @transactions ||= Services::TransactionService.new(self) |