monzo-cli 0.0.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21dff323f90b59f5cf45fbb4a19fc6691e92581f
4
- data.tar.gz: 3cd737d3b095fcfbe16785c4df077e03c11111aa
3
+ metadata.gz: eb93a7bc6981e68095aec985cfe9655a8bf83c87
4
+ data.tar.gz: d83d025b4a9af2ad779033dd5d18a0e53c48875a
5
5
  SHA512:
6
- metadata.gz: 3e408ce3f8fae7694e35a38d81a2884deadbcfd540bf92f9f41adf197b27a976ff5f35955a6b35ad7cade613315fd8f469037d509574c687ff49c8f6749dabee
7
- data.tar.gz: 8c8f099184b7f6987f493e33501a793675fe31886b0306ed5c2f7ff7a592935372c7e63f94702f35148e7a04131776688d6603d4f026bb1ad5f83924d0dad87b
6
+ metadata.gz: 737236b4c3d0b2d275aef873ad787e32f16c346ad44d209a9ed755e8612693303cba629ba9ac6582c5e3568497e5e0b92f9f09fb77eccb129f3d788c76d50f27
7
+ data.tar.gz: ebe13add379ca43bc8e3a16d46a7df301f01d8178c86d27ea5e3973f0e476a57b97b3ba2ab9fc068b2c29815c91b4f1a5f79f03c6452a11318eef8f2ecd25850
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- monzo-cli (0.0.1)
4
+ monzo-cli (0.2.1)
5
5
  activesupport (~> 3.2)
6
6
  colorize (~> 0.7)
7
7
  gli (= 2.14.0)
data/README.md CHANGED
@@ -14,11 +14,35 @@
14
14
  ```bash
15
15
  $ monzo-cli balance
16
16
 
17
- +---------+-------------+
18
- | Balance | Spent today |
19
- +---------+-------------+
20
- | £490 | £10 |
21
- +---------+-------------+
17
+ +---------+-------------+
18
+ | Balance | Spent today |
19
+ +---------+-------------+
20
+ | £490 | £10 |
21
+ +---------+-------------+
22
+ ```
23
+
24
+ ## Transactions list
25
+
26
+ ```bash
27
+ $ monzo-cli transactions
28
+
29
+ +----------+---------------------------+------------------------------------------+----------+
30
+ | Amount | date | Description | Balance |
31
+ +----------+---------------------------+------------------------------------------+----------+
32
+ | £ -5.59 | 2016-11-26T02:30:17+00:00 | Amazon EU AMAZON.CO.UK LUX | £ 37.42 |
33
+ +----------+---------------------------+------------------------------------------+----------+
34
+ | £ -46.99 | 2016-11-25T11:01:21+00:00 | Amazon Prime Now UK 811-111-1111 LUX | £ 43.01 |
35
+ +----------+---------------------------+------------------------------------------+----------+
36
+ | £ 1.00 | 2016-11-25T11:00:55+00:00 | Amazon Prime Now UK 811-111-1111 LUX | £ 90.00 |
37
+ +----------+---------------------------+------------------------------------------+----------+
38
+ | £ -1.00 | 2016-11-25T11:00:54+00:00 | Amazon Prime Now UK 811-111-1111 LUX | £ 89.00 |
39
+ +----------+---------------------------+------------------------------------------+----------+
40
+ | £ -10.00 | 2016-11-25T09:39:47+00:00 | SKY RESTAURANT STAFF TOP UP GBR | £ 90.00 |
41
+ +----------+---------------------------+------------------------------------------+----------+
42
+ | £ 0.00 | 2016-11-25T08:59:17+00:00 | Uber BV help.uber.com NLD | £ 100.00 |
43
+ +----------+---------------------------+------------------------------------------+----------+
44
+ | £ 100.00 | 2016-11-24T20:00:02+00:00 | Initial top up | £ 100.00 |
45
+ +----------+---------------------------+------------------------------------------+----------+
22
46
  ```
23
47
 
24
48
  ## Accounts
@@ -26,11 +50,11 @@ $ monzo-cli balance
26
50
  ```bash
27
51
  $ monzo-cli accounts
28
52
 
29
- +---------------------+----------------------+
30
- | Description | Date created |
31
- +---------------------+----------------------+
32
- | Peter Pans Account | 2015-11-13T12:17:42Z |
33
- +---------------------+----------------------+
53
+ +---------------------+----------------------+
54
+ | Description | Date created |
55
+ +---------------------+----------------------+
56
+ | Peter Pans Account | 2015-11-13T12:17:42Z |
57
+ +---------------------+----------------------+
34
58
  ```
35
59
 
36
60
  ## Install
@@ -39,9 +63,10 @@ $ monzo-cli accounts
39
63
  gem install monzo-cli
40
64
  ```
41
65
 
66
+ ## Setup
42
67
  Get your access tokens from this URL: https://developers.getmondo.co.uk/api/playground
43
-
44
-
68
+
69
+
45
70
  Please create/edit it on `~/.monzo-cli.yml` with this format:
46
71
 
47
72
 
@@ -51,7 +76,10 @@ account_id: acc_0aksdaklsjSh28181
51
76
  access_token: Qnjdas8hakxdjasQscGVgnVGIVXpvpZ5uCxkQ5XLnDHnOPoBtXreQ6adBo
52
77
 
53
78
  ```
54
-
79
+
80
+ ## Caveats
81
+ - Right now the `access_token` expires everyday, still need to find a way to refresh it automatically
82
+
55
83
  ## Contributing
56
84
  I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:
57
85
  1. If its a feature, bugfix, or anything please only change code to what you specify.
data/bin/monzo-cli CHANGED
@@ -50,7 +50,7 @@ command :balance do |c|
50
50
  table = Terminal::Table.new do |t|
51
51
  t << ['Balance', 'Spent today']
52
52
  t << :separator
53
- t << ["£#{balance}".green, "£#{spent_today}".green]
53
+ t << ["£ #{balance}".green, "£ #{spent_today}".green]
54
54
  end
55
55
 
56
56
  puts table
@@ -62,7 +62,20 @@ desc 'List your transactions'
62
62
  arg_name 'Maybe pagination'
63
63
  command :transactions do |c|
64
64
  c.action do |global_options, options, args|
65
- puts 'transactions command ran'
65
+
66
+ transactions = MonzoApi.new(@config).transactions
67
+
68
+ table = Terminal::Table.new do |t|
69
+ t << %w(Amount date Description Balance)
70
+
71
+ transactions.each { |item|
72
+ t << :separator
73
+ t << ["£ #{item.amount}".green, item.created, item.description, "£ #{item.account_balance}".green]
74
+ }
75
+ end
76
+
77
+ puts table
78
+
66
79
  end
67
80
  end
68
81
 
@@ -98,17 +111,8 @@ end
98
111
 
99
112
 
100
113
  def show_no_config_found_error
101
-
102
- open_operation = "vim #{@path_to_config}".green
103
-
104
114
  puts "\nError reading from #{@path_to_config.green}"
105
- puts "Get your information from this URL: https://developers.getmondo.co.uk/api/playground"
106
- puts "Please create/edit it with #{open_operation} with this format:\n\n"
107
-
108
- puts " user_id: user_18231092askdas9212".yellow
109
- puts " account_id: acc_0aksdaklsjSh28181".yellow
110
- puts " access_token: Qnjdas8hakxdjasQscGVgnVGIVXpvpZ5uCxkQ5XLnDHnOPoBtXreQ6adBo".yellow
111
-
115
+ puts 'Instructions to set everything up in here: https://github.com/cesarferreira/monzo-cli#setup'
112
116
  puts "\n\n"
113
117
  end
114
118
 
@@ -5,7 +5,7 @@ module Mondo
5
5
  end
6
6
 
7
7
  def spent_today
8
- Money.new(raw_data['spent_today'], currency)
8
+ Money.new(raw_data['spend_today'], currency)
9
9
  end
10
10
 
11
11
  def currency
@@ -116,10 +116,10 @@ module Mondo
116
116
 
117
117
  # @method transactions
118
118
  # @return [Transactions] all transactions for this user
119
- def transactions(opts = {})
120
- raise ClientError.new("You must provide an account id to query transactions") unless self.account_id
121
- opts.merge!(account_id: self.account_id)
122
- resp = api_get("/transactions", opts)
119
+ def transactions(account_id = nil)
120
+ account_id ||= self.account_id
121
+ raise ClientError.new("You must provide an account id to see your balance") unless account_id
122
+ resp = api_get("transactions", account_id: account_id)
123
123
  return resp if resp.error.present?
124
124
  resp.parsed["transactions"].map { |tx| Transaction.new(tx, self) }
125
125
  end
@@ -164,9 +164,6 @@ module Mondo
164
164
  raise ClientError.new("You must provide an account id to list webhooks") unless self.account_id
165
165
  @web_hooks ||= begin
166
166
  resp = api_get("webhooks", account_id: self.account_id)
167
-
168
- puts resp.inspect
169
-
170
167
  resp.parsed['webhooks'].map { |hook| WebHook.new(hook, self) }
171
168
  end
172
169
  end
@@ -21,7 +21,7 @@ class MonzoApi
21
21
  end
22
22
 
23
23
  def transactions
24
- @monzo.transactions
24
+ @monzo.transactions(@account_id).reverse
25
25
  end
26
26
 
27
27
  end
data/lib/monzo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Monzo
2
- VERSION = '0.0.1'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monzo-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cesar ferreira