Class: Monzo::Client
- Inherits:
-
Object
- Object
- Monzo::Client
- Defined in:
- lib/monzo/client.rb
Overview
Internal: A client to perform HTTPS requests to the Monzo API.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Public: Returns the access token used to authenticate with.
Instance Method Summary collapse
-
#delete(path) ⇒ Object
Internal: Perform a DELETE request to the Monzo API.
-
#get(path, options = {}) ⇒ Object
Internal: Perform a GET request to the Monzo API.
-
#initialize(access_token) ⇒ Client
constructor
Public: Initialize a Monzo::Client to make HTTP requests.
-
#patch(path, data, options = {}) ⇒ Object
Internal: Perform a PATCH request to the Monzo API.
-
#post(path, data, options = {}) ⇒ Object
Internal: Perform a POST request to the Monzo API.
-
#put(path, data, options = {}) ⇒ Object
Internal: Perform a PUT request to the Monzo API.
Constructor Details
#initialize(access_token) ⇒ Client
Public: Initialize a Monzo::Client to make HTTP requests
access_token - The access_token to authenticate with.
15 16 17 |
# File 'lib/monzo/client.rb', line 15 def initialize(access_token) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Public: Returns the access token used to authenticate with.
10 11 12 |
# File 'lib/monzo/client.rb', line 10 def access_token @access_token end |
Instance Method Details
#delete(path) ⇒ Object
Internal: Perform a DELETE request to the Monzo API.
path - The URI path to request.
Returns a HTTP response.
90 91 92 93 94 95 96 97 |
# File 'lib/monzo/client.rb', line 90 def delete(path) uri = build_uri(path) request = Net::HTTP::Delete.new(uri.request_uri) (request) response = https_client(uri).request(request) end |
#get(path, options = {}) ⇒ Object
Internal: Perform a GET request to the Monzo API.
path - The URI path to request. options - A Hash of query options to include in the URI.
Returns a HTTP response.
25 26 27 28 29 30 31 32 |
# File 'lib/monzo/client.rb', line 25 def get(path, = {}) uri = build_uri(path, ) request = Net::HTTP::Get.new(uri.request_uri) (request) response = https_client(uri).request(request) end |
#patch(path, data, options = {}) ⇒ Object
Internal: Perform a PATCH request to the Monzo API.
path - The URI path to request. data - The form data to send with the request. options - A Hash of query options to include in the URI.
Returns a HTTP response.
58 59 60 61 62 63 64 65 66 |
# File 'lib/monzo/client.rb', line 58 def patch(path, data, = {}) uri = build_uri(path, ) request = Net::HTTP::Patch.new(uri.request_uri) (request) request.set_form_data(data) response = https_client(uri).request(request) end |
#post(path, data, options = {}) ⇒ Object
Internal: Perform a POST request to the Monzo API.
path - The URI path to request. data - The form data to send with the request. options - A Hash of query options to include in the URI.
Returns a HTTP response.
41 42 43 44 45 46 47 48 49 |
# File 'lib/monzo/client.rb', line 41 def post(path, data, = {}) uri = build_uri(path, ) request = Net::HTTP::Post.new(uri.request_uri) (request) request.set_form_data(data) response = https_client(uri).request(request) end |
#put(path, data, options = {}) ⇒ Object
Internal: Perform a PUT request to the Monzo API.
path - The URI path to request. data - The form data to send with the request. options - A Hash of query options to include in the URI.
Returns a HTTP response.
75 76 77 78 79 80 81 82 83 |
# File 'lib/monzo/client.rb', line 75 def put(path, data, = {}) uri = build_uri(path, ) request = Net::HTTP::Put.new(uri.request_uri) (request) request.set_form_data(data) response = https_client(uri).request(request) end |