-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Accounts endpoint functionality
- Loading branch information
1 parent
459910b
commit ce0680b
Showing
9 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
require "spec" | ||
require "../src/monzo.cr" | ||
require "../src/monzo" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Monzo | ||
module API | ||
class Accounts | ||
delegate :host, :headers, to: Monzo::Client | ||
|
||
def initialize | ||
@base_url = "#{host}/accounts" | ||
end | ||
|
||
def list | ||
response = HTTP::Client.get(@base_url, headers: headers) | ||
|
||
Array(Account).from_json(response.body, "accounts") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Monzo | ||
class Client | ||
Habitat.create do | ||
setting user_id : String | ||
setting account_id : String | ||
setting access_token : String | ||
setting base_url : String | ||
end | ||
|
||
def self.headers | ||
@@headers ||= HTTP::Headers { | ||
"Authorization" => "Bearer #{settings.access_token}" | ||
} | ||
end | ||
|
||
def self.host | ||
settings.base_url | ||
end | ||
|
||
def self.accounts | ||
Monzo::API::Accounts.new | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Account | ||
include JSON::Serializable | ||
|
||
property id : String | ||
property closed : Bool | ||
|
||
@[JSON::Field(converter: Time::Format.new("%F"))] | ||
property created : Time | ||
|
||
property description : String | ||
property type : String | ||
property currency : String | ||
property country_code : String | ||
property owners : Array(Owner) | ||
property payment_details : PaymentDetails | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Locales | ||
class US | ||
include JSON::Serializable | ||
|
||
property account_number : String | ||
property routing_number : String | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Owner | ||
include JSON::Serializable | ||
|
||
property user_id : String | ||
property preferred_name : String | ||
property preferred_first_name : String | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class PaymentDetails | ||
include JSON::Serializable | ||
|
||
property locale_us : Locales::US | ||
end |