monobank 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/monobank.rb +1 -1
- data/lib/monobank/bank/currency.rb +2 -2
- data/lib/monobank/client.rb +6 -1
- data/lib/monobank/connection.rb +4 -0
- data/lib/monobank/methods/base.rb +35 -0
- data/lib/monobank/methods/get.rb +15 -0
- data/lib/monobank/methods/post.rb +15 -0
- data/lib/monobank/personal/client_info.rb +2 -2
- data/lib/monobank/personal/statement.rb +2 -2
- data/lib/monobank/personal/webhook.rb +31 -0
- data/lib/monobank/resources/error.rb +1 -1
- data/lib/monobank/resources/personal/webhook.rb +12 -0
- data/lib/monobank/version.rb +1 -1
- metadata +9 -9
- data/lib/monobank/endpoint.rb +0 -24
- data/spec/monobank_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3875523c369f56b0b6a1cbaa1c86394ddf8ed4060baef32f8e1c7e43851a0ac
|
4
|
+
data.tar.gz: 31e57627ab4ae406ccea2815745fcd93887f09a68939ab12e5470e6440c692ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472156cfe0897fdeb10542915a5b9d7d82df0fc72e9eefc53ba2827c9c34a802168ade061aeb2b5e2184a1b2d2a842be187f1268c38aeb013373ae0194c82ee2
|
7
|
+
data.tar.gz: ed3f5f077c2870b4d13da80156c84730746e21b4d72ca443a116b5923002eb4bcc92419b2332a948a866a0ebfc2104af7267cd5fb39375bb66dd1a08355a78cf
|
data/lib/monobank.rb
CHANGED
data/lib/monobank/client.rb
CHANGED
@@ -2,6 +2,7 @@ require 'monobank/connection'
|
|
2
2
|
require 'monobank/bank/currency'
|
3
3
|
require 'monobank/personal/client_info'
|
4
4
|
require 'monobank/personal/statement'
|
5
|
+
require 'monobank/personal/webhook'
|
5
6
|
|
6
7
|
module Monobank
|
7
8
|
class Client
|
@@ -16,5 +17,9 @@ module Monobank
|
|
16
17
|
def statement(token:, account_id:, from:, to: nil)
|
17
18
|
Personal::Statement.new(token: token, account_id: account_id, from: from, to: to).call
|
18
19
|
end
|
20
|
+
|
21
|
+
def set_webhook(token:, url:)
|
22
|
+
Personal::Webhook.new(token: token, url: url).call
|
23
|
+
end
|
19
24
|
end
|
20
|
-
end
|
25
|
+
end
|
data/lib/monobank/connection.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'monobank/resources/error'
|
2
|
+
|
3
|
+
module Monobank
|
4
|
+
module Methods
|
5
|
+
class Base
|
6
|
+
def call
|
7
|
+
attributes = response
|
8
|
+
return define_resources(attributes) if attributes.code == 200
|
9
|
+
|
10
|
+
Monobank::Resources::Error.new(attributes.merge('code' => attributes.code))
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :token
|
16
|
+
|
17
|
+
def response
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
|
21
|
+
def options
|
22
|
+
{
|
23
|
+
headers: { 'X-Token' => token.to_s },
|
24
|
+
body: body.to_json
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def body; end
|
29
|
+
|
30
|
+
def connection
|
31
|
+
@connection ||= Connection.new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'monobank/
|
1
|
+
require 'monobank/methods/get'
|
2
2
|
require 'monobank/resources/personal/client_info'
|
3
3
|
|
4
4
|
module Monobank
|
5
5
|
module Personal
|
6
|
-
class ClientInfo <
|
6
|
+
class ClientInfo < Methods::Get
|
7
7
|
ENDPOINT = '/personal/client-info'.freeze
|
8
8
|
|
9
9
|
def initialize(token:)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'monobank/
|
1
|
+
require 'monobank/methods/get'
|
2
2
|
require 'monobank/resources/personal/statement'
|
3
3
|
|
4
4
|
module Monobank
|
5
5
|
module Personal
|
6
|
-
class Statement <
|
6
|
+
class Statement < Methods::Get
|
7
7
|
ENDPOINT = '/personal/statement'.freeze
|
8
8
|
|
9
9
|
def initialize(token:, account_id:, from:, to:)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'monobank/methods/post'
|
2
|
+
require 'monobank/resources/personal/webhook'
|
3
|
+
|
4
|
+
module Monobank
|
5
|
+
module Personal
|
6
|
+
class Webhook < Methods::Post
|
7
|
+
ENDPOINT = '/personal/webhook'.freeze
|
8
|
+
|
9
|
+
def initialize(token:, url:)
|
10
|
+
@token = token
|
11
|
+
@url = url
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :url
|
17
|
+
|
18
|
+
def pathname
|
19
|
+
ENDPOINT
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
{ webHookUrl: url }
|
24
|
+
end
|
25
|
+
|
26
|
+
def define_resources(attributes)
|
27
|
+
Monobank::Resources::Personal::Webhook.new(attributes)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/monobank/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monobank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vergilet
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-01-
|
12
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashable
|
@@ -51,19 +51,21 @@ files:
|
|
51
51
|
- lib/monobank/bank/currency.rb
|
52
52
|
- lib/monobank/client.rb
|
53
53
|
- lib/monobank/connection.rb
|
54
|
-
- lib/monobank/endpoint.rb
|
55
54
|
- lib/monobank/error.rb
|
55
|
+
- lib/monobank/methods/base.rb
|
56
|
+
- lib/monobank/methods/get.rb
|
57
|
+
- lib/monobank/methods/post.rb
|
56
58
|
- lib/monobank/personal/client_info.rb
|
57
59
|
- lib/monobank/personal/statement.rb
|
60
|
+
- lib/monobank/personal/webhook.rb
|
58
61
|
- lib/monobank/resources/bank/currency.rb
|
59
62
|
- lib/monobank/resources/base.rb
|
60
63
|
- lib/monobank/resources/error.rb
|
61
64
|
- lib/monobank/resources/personal/accounts.rb
|
62
65
|
- lib/monobank/resources/personal/client_info.rb
|
63
66
|
- lib/monobank/resources/personal/statement.rb
|
67
|
+
- lib/monobank/resources/personal/webhook.rb
|
64
68
|
- lib/monobank/version.rb
|
65
|
-
- spec/monobank_spec.rb
|
66
|
-
- spec/spec_helper.rb
|
67
69
|
homepage: https://github.com/vergilet/monobank
|
68
70
|
licenses:
|
69
71
|
- MIT
|
@@ -86,10 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
88
|
- !ruby/object:Gem::Version
|
87
89
|
version: '0'
|
88
90
|
requirements: []
|
89
|
-
rubygems_version: 3.0.
|
91
|
+
rubygems_version: 3.0.6
|
90
92
|
signing_key:
|
91
93
|
specification_version: 4
|
92
94
|
summary: Unofficial Ruby Gem for Monobank API.
|
93
|
-
test_files:
|
94
|
-
- spec/spec_helper.rb
|
95
|
-
- spec/monobank_spec.rb
|
95
|
+
test_files: []
|
data/lib/monobank/endpoint.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'monobank/resources/error'
|
2
|
-
|
3
|
-
module Monobank
|
4
|
-
class Endpoint
|
5
|
-
def call
|
6
|
-
attributes = connection.get(pathname, options)
|
7
|
-
return define_resources(attributes) if attributes.success?
|
8
|
-
|
9
|
-
Monobank::Resources::Error.new(attributes)
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
attr_reader :token
|
15
|
-
|
16
|
-
def options
|
17
|
-
{ headers: { "X-Token" => token.to_s } }
|
18
|
-
end
|
19
|
-
|
20
|
-
def connection
|
21
|
-
@connection ||= Connection.new
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/spec/monobank_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require "monobank"
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
# Enable flags like --only-failures and --next-failure
|
6
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
-
|
8
|
-
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
-
config.disable_monkey_patching!
|
10
|
-
|
11
|
-
config.expect_with :rspec do |c|
|
12
|
-
c.syntax = :expect
|
13
|
-
end
|
14
|
-
end
|