monobank-ruby 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dbbfb58d7f2abd3afdf4234ed866db6f15d576cb8f300a831cb04eba9344bd94
4
+ data.tar.gz: a46816a17e0da70ea819e837737dec6e5657594a3144b2adeba2bee2c889b4df
5
+ SHA512:
6
+ metadata.gz: 23d32c378bfdc175021911c2b151dd81265ae50f3266700bf46500b9f191b6c28e653e21539af37a7571a7dd912d6ba567e0c8bb8e7b7526fef16dd0b91c02ee
7
+ data.tar.gz: 5d5dea97600c0c467ec8e042622fa618b45c5a9bfd7932e1912db0696f420e7cc914e467f42c7159d545718eb60e4cbcaa9eb77065f7e90591ae5e5fc1ec178e
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/bundle
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.2
7
+ before_install: gem install bundler -v 1.17.3
@@ -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 yaroslav.bezrukavyi@gmail.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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in monobank-ruby.gemspec
8
+ gemspec
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ monobank-ruby (0.1.0)
5
+ api_struct (~> 1.0, >= 1.0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ api_struct (1.0.3)
13
+ dry-configurable (~> 0.7.0)
14
+ dry-inflector (~> 0.1.2)
15
+ dry-monads (~> 1.0)
16
+ hashie (~> 3.5, >= 3.5.6)
17
+ http (>= 2.0.3)
18
+ ast (2.4.0)
19
+ coderay (1.1.2)
20
+ concurrent-ruby (1.1.5)
21
+ diff-lcs (1.3)
22
+ domain_name (0.5.20180417)
23
+ unf (>= 0.0.5, < 1.0.0)
24
+ dry-configurable (0.7.0)
25
+ concurrent-ruby (~> 1.0)
26
+ dry-core (0.4.8)
27
+ concurrent-ruby (~> 1.0)
28
+ dry-equalizer (0.2.2)
29
+ dry-inflector (0.1.2)
30
+ dry-monads (1.2.0)
31
+ concurrent-ruby (~> 1.0)
32
+ dry-core (~> 0.4, >= 0.4.4)
33
+ dry-equalizer
34
+ hashie (3.6.0)
35
+ http (4.1.1)
36
+ addressable (~> 2.3)
37
+ http-cookie (~> 1.0)
38
+ http-form_data (~> 2.0)
39
+ http_parser.rb (~> 0.6.0)
40
+ http-cookie (1.0.3)
41
+ domain_name (~> 0.5)
42
+ http-form_data (2.1.1)
43
+ http_parser.rb (0.6.0)
44
+ method_source (0.9.2)
45
+ parallel (1.17.0)
46
+ parser (2.6.3.0)
47
+ ast (~> 2.4.0)
48
+ powerpack (0.1.2)
49
+ pry (0.12.2)
50
+ coderay (~> 1.1.0)
51
+ method_source (~> 0.9.0)
52
+ public_suffix (3.1.0)
53
+ rainbow (3.0.0)
54
+ rake (10.5.0)
55
+ rspec (3.8.0)
56
+ rspec-core (~> 3.8.0)
57
+ rspec-expectations (~> 3.8.0)
58
+ rspec-mocks (~> 3.8.0)
59
+ rspec-core (3.8.1)
60
+ rspec-support (~> 3.8.0)
61
+ rspec-expectations (3.8.4)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.8.0)
64
+ rspec-mocks (3.8.1)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.8.0)
67
+ rspec-support (3.8.2)
68
+ rubocop (0.55.0)
69
+ parallel (~> 1.10)
70
+ parser (>= 2.5)
71
+ powerpack (~> 0.1)
72
+ rainbow (>= 2.2.2, < 4.0)
73
+ ruby-progressbar (~> 1.7)
74
+ unicode-display_width (~> 1.0, >= 1.0.1)
75
+ ruby-progressbar (1.10.1)
76
+ unf (0.1.4)
77
+ unf_ext
78
+ unf_ext (0.0.7.6)
79
+ unicode-display_width (1.6.0)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler (~> 1.17)
86
+ monobank-ruby!
87
+ pry
88
+ rake (~> 10.0)
89
+ rspec (~> 3.0)
90
+ rubocop (~> 0.55.0)
91
+
92
+ BUNDLED WITH
93
+ 1.17.3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 bezrukavyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Monobank Ruby
2
+
3
+ Ruby gem for [Monobank API](https://api.monobank.ua/docs)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'monobank-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install monobank-ruby
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'monobank-ruby'
25
+
26
+ token = 'YOUR_TOKEN'
27
+
28
+ info = Monobank::ClientInfo.show(token) # {"name"=>"Безрукавий Ярослав", "accounts"=>[{"id"=>"SOME_ID", "currencyCode"=>000, "cashbackType"=>"UAH", "balance"=>000, "creditLimit"=>000}]}
29
+
30
+ from = '1560588240' # 10.days.ago.to_i
31
+
32
+ info.accounts.first.statement(from: from, token: token) # [{"id"=>"SOME_IUD", "time"=>1561390362, "description"=>"TERMINAL8", "mcc"=>0000, "amount"=>000, "operation_amount"=>000, "currency_code"=>000, "commission_rate"=>0, "cashback_amount"=>000, "balance"=>000, "hold"=>true},
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/monobank-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+
43
+ ## Code of Conduct
44
+
45
+ Everyone interacting in the Monobank::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/monobank-ruby/blob/master/CODE_OF_CONDUCT.md).
@@ -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 "monobank/ruby"
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
+ # frozen_string_literal: true
2
+
3
+ require 'api_struct'
4
+
5
+ require_relative 'monobank/version'
6
+ require_relative 'monobank/initializers/api_struct'
7
+
8
+ require_relative 'monobank/clients/base_client'
9
+ require_relative 'monobank/clients/client_info'
10
+ require_relative 'monobank/clients/statement'
11
+
12
+ require_relative 'monobank/account'
13
+ require_relative 'monobank/client_info'
14
+ require_relative 'monobank/statement'
15
+
16
+ module Monobank
17
+ class Error < StandardError; end
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ class Account < ApiStruct::Entity
5
+ attr_entity :id, :balance, :credit_limit, :currency_code, :cashback_type
6
+
7
+ def statement(from:, to: nil, token:)
8
+ Monobank::Statement.show(account: id, from: from, to: to, token: token)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ class ClientInfo < ApiStruct::Entity
5
+ client_service Monobank::Clients::ClientInfo
6
+
7
+ attr_entity :name, :id
8
+
9
+ has_entities :accounts, as: Monobank::Account
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ module Clients
5
+ class Base < ApiStruct::Client
6
+ TOKEN_HEADER = 'X-Token'
7
+
8
+ def default_headers(token)
9
+ { TOKEN_HEADER => token }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ module Clients
5
+ class ClientInfo < Monobank::Clients::Base
6
+ monobank_api 'personal/client-info'
7
+
8
+ def show(token)
9
+ get(headers: default_headers(token))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ module Clients
5
+ class Statement < Monobank::Clients::Base
6
+ monobank_api 'personal/statement'
7
+
8
+ def show(account:, from:, to:, token:)
9
+ get("#{account}/#{from}/#{to}", headers: default_headers(token))
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ ApiStruct::Settings.configure do |config|
2
+ config.endpoints = {
3
+ monobank_api: {
4
+ root: 'https://api.monobank.ua',
5
+ headers: {}
6
+ }
7
+ }
8
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monobank
4
+ class Statement < ApiStruct::Entity
5
+ client_service Monobank::Clients::Statement
6
+
7
+ attr_entity :id, :time, :description, :mcc, :hold, :amount,
8
+ :operation_amount, :currency_code, :commission_rate,
9
+ :cashback_amount, :balance
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Monobank
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'monobank/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'monobank-ruby'
9
+ spec.version = Monobank::VERSION
10
+ spec.authors = ['bezrukavyi']
11
+ spec.email = ['yaroslav.bezrukavyi@gmail.com']
12
+
13
+ spec.summary = 'Gem for Monobank API'
14
+ spec.description = 'Gem for Monobank API'
15
+ spec.homepage = 'https://github.com/bezrukavyi/monobank-ruby'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_dependency 'api_struct', '~> 1.0', '>= 1.0.3'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.17'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'rubocop', '~> 0.55.0'
32
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: monobank-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - bezrukavyi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: api_struct
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.17'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.17'
47
+ - !ruby/object:Gem::Dependency
48
+ name: pry
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.55.0
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.55.0
103
+ description: Gem for Monobank API
104
+ email:
105
+ - yaroslav.bezrukavyi@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".travis.yml"
113
+ - CODE_OF_CONDUCT.md
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - bin/console
120
+ - bin/setup
121
+ - lib/monobank.rb
122
+ - lib/monobank/account.rb
123
+ - lib/monobank/client_info.rb
124
+ - lib/monobank/clients/base_client.rb
125
+ - lib/monobank/clients/client_info.rb
126
+ - lib/monobank/clients/statement.rb
127
+ - lib/monobank/initializers/api_struct.rb
128
+ - lib/monobank/statement.rb
129
+ - lib/monobank/version.rb
130
+ - monobank-ruby.gemspec
131
+ homepage: https://github.com/bezrukavyi/monobank-ruby
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubygems_version: 3.0.3
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Gem for Monobank API
154
+ test_files: []