moneylovercli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +6 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +9 -0
  8. data/Gemfile.lock +67 -0
  9. data/LICENSE.txt +20 -0
  10. data/README.md +45 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/exe/moneylovercli +18 -0
  15. data/lib/moneylovercli.rb +7 -0
  16. data/lib/moneylovercli/api/access_token.rb +19 -0
  17. data/lib/moneylovercli/api/base.rb +15 -0
  18. data/lib/moneylovercli/api/category.rb +15 -0
  19. data/lib/moneylovercli/api/money_lover.rb +14 -0
  20. data/lib/moneylovercli/api/transaction.rb +25 -0
  21. data/lib/moneylovercli/api/user.rb +13 -0
  22. data/lib/moneylovercli/api/wallet.rb +13 -0
  23. data/lib/moneylovercli/cli.rb +62 -0
  24. data/lib/moneylovercli/command.rb +141 -0
  25. data/lib/moneylovercli/commands/.gitkeep +1 -0
  26. data/lib/moneylovercli/commands/add_transaction.rb +74 -0
  27. data/lib/moneylovercli/commands/login.rb +61 -0
  28. data/lib/moneylovercli/commands/wallets.rb +31 -0
  29. data/lib/moneylovercli/version.rb +4 -0
  30. data/moneylovercli.gemspec +33 -0
  31. data/sorbet/config +2 -0
  32. data/sorbet/rbi/gems/byebug.rbi +1041 -0
  33. data/sorbet/rbi/gems/coderay.rbi +92 -0
  34. data/sorbet/rbi/gems/equatable.rbi +26 -0
  35. data/sorbet/rbi/gems/httparty.rbi +421 -0
  36. data/sorbet/rbi/gems/method_source.rbi +64 -0
  37. data/sorbet/rbi/gems/mime-types-data.rbi +17 -0
  38. data/sorbet/rbi/gems/mime-types.rbi +218 -0
  39. data/sorbet/rbi/gems/multi_xml.rbi +35 -0
  40. data/sorbet/rbi/gems/pastel.rbi +128 -0
  41. data/sorbet/rbi/gems/pry-byebug.rbi +155 -0
  42. data/sorbet/rbi/gems/pry.rbi +1949 -0
  43. data/sorbet/rbi/gems/rake.rbi +645 -0
  44. data/sorbet/rbi/gems/rspec-core.rbi +1923 -0
  45. data/sorbet/rbi/gems/rspec-expectations.rbi +1123 -0
  46. data/sorbet/rbi/gems/rspec-mocks.rbi +1090 -0
  47. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  48. data/sorbet/rbi/gems/rspec.rbi +15 -0
  49. data/sorbet/rbi/gems/tty-color.rbi +44 -0
  50. data/sorbet/rbi/gems/zeitwerk.rbi +136 -0
  51. data/sorbet/rbi/hidden-definitions/errors.txt +4361 -0
  52. data/sorbet/rbi/hidden-definitions/hidden.rbi +8227 -0
  53. data/sorbet/rbi/sorbet-typed/lib/httparty/all/httparty.rbi +427 -0
  54. data/sorbet/rbi/todo.rbi +20 -0
  55. metadata +167 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 49b8f9e1d7b921929e56094d843063ce8cc5953b53e5b695b589341b46ddd859
4
+ data.tar.gz: 54c5e9a342a7b7c56f0553c71b96ad744fdd102096fe78a01a4a5ad4f00096a1
5
+ SHA512:
6
+ metadata.gz: 31578504edaf54e09ab0a87fac6a03c79d68cd1a21ec382e206d11f49268af5c03a794433b7d2976f67d7f52869703067424e8d00979295515483e3c315e1abe
7
+ data.tar.gz: 25e774c792a3c0bc7f9016df3c52bd4dc6c354d625654db797873ffc75be4b8e8b58c63f8e5883cb9df5e294cd261474f47414ce8b3069c87865bf432cd67a6c
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .byebug_history
14
+ config.yml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.7.0
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at cuong.ngo@employmenthero.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in moneylovercli.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem 'sorbet', :group => :development
9
+ gem 'sorbet-runtime'
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ moneylovercli (0.1.0)
5
+ byebug
6
+ httparty
7
+ pastel (= 0.7.4)
8
+ pry-byebug
9
+ zeitwerk
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ byebug (11.1.3)
15
+ coderay (1.1.3)
16
+ diff-lcs (1.4.4)
17
+ equatable (0.6.1)
18
+ httparty (0.18.1)
19
+ mime-types (~> 3.0)
20
+ multi_xml (>= 0.5.2)
21
+ method_source (1.0.0)
22
+ mime-types (3.3.1)
23
+ mime-types-data (~> 3.2015)
24
+ mime-types-data (3.2020.0512)
25
+ multi_xml (0.6.0)
26
+ pastel (0.7.4)
27
+ equatable (~> 0.6)
28
+ tty-color (~> 0.5)
29
+ pry (0.13.1)
30
+ coderay (~> 1.1)
31
+ method_source (~> 1.0)
32
+ pry-byebug (3.9.0)
33
+ byebug (~> 11.0)
34
+ pry (~> 0.13.0)
35
+ rake (12.3.3)
36
+ rspec (3.9.0)
37
+ rspec-core (~> 3.9.0)
38
+ rspec-expectations (~> 3.9.0)
39
+ rspec-mocks (~> 3.9.0)
40
+ rspec-core (3.9.2)
41
+ rspec-support (~> 3.9.3)
42
+ rspec-expectations (3.9.2)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.9.0)
45
+ rspec-mocks (3.9.1)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.9.0)
48
+ rspec-support (3.9.3)
49
+ sorbet (0.5.5909)
50
+ sorbet-static (= 0.5.5909)
51
+ sorbet-runtime (0.5.5909)
52
+ sorbet-static (0.5.5909-universal-darwin-14)
53
+ tty-color (0.5.2)
54
+ zeitwerk (2.4.0)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ moneylovercli!
61
+ rake (~> 12.0)
62
+ rspec (~> 3.0)
63
+ sorbet
64
+ sorbet-runtime
65
+
66
+ BUNDLED WITH
67
+ 2.1.2
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 cuongn265
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Moneylovercli
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/moneylovercli`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'moneylovercli'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install moneylovercli
22
+
23
+ ## Usage
24
+
25
+ $ moneylovercli login
26
+ $ moneylovercli add_transaction
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/moneylovercli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/moneylovercli/blob/master/CODE_OF_CONDUCT.md).
37
+
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the Moneylovercli project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/moneylovercli/blob/master/CODE_OF_CONDUCT.md).
42
+
43
+ ## Copyright
44
+
45
+ Copyright (c) 2020 cuongn265. See [MIT License](LICENSE.txt) for further details.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "moneylovercli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'moneylovercli/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Moneylovercli::CLI.start
15
+ rescue Moneylovercli::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
@@ -0,0 +1,7 @@
1
+ # typed: strict
2
+ require "moneylovercli/version"
3
+
4
+ module Moneylovercli
5
+ class Error < StandardError; end
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,19 @@
1
+ # typed: strict
2
+ require_relative './base.rb'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class AccessToken < Base
7
+ base_uri 'https://oauth.moneylover.me'
8
+
9
+ sig do
10
+ params(authorization_token: String, client: String, email: String, password: String)
11
+ .returns(HTTParty::Response)
12
+ end
13
+ def access_token(authorization_token:, client:, email:, password:)
14
+ self.class.post('/token', body: { email: email, password: password },
15
+ headers: { authorization: "Bearer #{authorization_token}", client: client })
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # typed: true
2
+ require 'sorbet-runtime'
3
+ require 'httparty'
4
+
5
+ module Moneylovercli
6
+ module Api
7
+ class Base
8
+ attr_accessor :token
9
+ extend T::Sig
10
+ include HTTParty
11
+
12
+ base_uri 'https://web.moneylover.me/api/'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # typed: true
2
+ require 'sorbet-runtime'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class Category < MoneyLover
7
+ sig { params(wallet_id: String).returns(HTTParty::Response) }
8
+
9
+ def list(wallet_id:)
10
+ self.class.post('/category/list', body: { walletId: wallet_id },
11
+ headers: { authorization: "AuthJWT #{@token}" })
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # typed: true
2
+ require_relative './base.rb'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class MoneyLover < Base
7
+ attr_accessor :token
8
+
9
+ def initialize(token:)
10
+ @token = token
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ # typed: true
2
+ require 'sorbet-runtime'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class Transaction < MoneyLover
7
+ sig do
8
+ params(account: String, category_id: String, amount: Integer, display_date: String)
9
+ .returns(HTTParty::Response)
10
+ end
11
+
12
+ def add(account:, category_id:, amount:, display_date:)
13
+ self.class.post('/transaction/add',
14
+ body: {
15
+ account: account,
16
+ category: category_id,
17
+ amount: amount,
18
+ displayDate: display_date
19
+ },
20
+ headers: { authorization: "AuthJWT #{@token}" })
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,13 @@
1
+ # typed: strict
2
+ require_relative './base.rb'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class User < Base
7
+ sig { returns(HTTParty::Response) }
8
+ def login_url
9
+ self.class.post('/user/login-url', body: {})
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # typed: true
2
+ require_relative './money_lover'
3
+
4
+ module Moneylovercli
5
+ module Api
6
+ class Wallet < MoneyLover
7
+ sig { returns(HTTParty::Response) }
8
+ def list
9
+ self.class.post('/wallet/list', body: {}, headers: { authorization: "AuthJWT #{@token}" })
10
+ end
11
+ end
12
+ end
13
+ end