tikkie-api 0.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +20 -16
  3. data/.travis.yml +5 -5
  4. data/Gemfile +3 -2
  5. data/Gemfile.lock +23 -24
  6. data/LICENSE.txt +1 -1
  7. data/README.md +198 -69
  8. data/lib/tikkie/api.rb +52 -25
  9. data/lib/tikkie/api/amount.rb +35 -0
  10. data/lib/tikkie/api/client.rb +16 -8
  11. data/lib/tikkie/api/clients/base.rb +16 -0
  12. data/lib/tikkie/api/clients/payment_requests.rb +25 -0
  13. data/lib/tikkie/api/clients/payment_requests_subscription.rb +20 -0
  14. data/lib/tikkie/api/clients/payments.rb +20 -0
  15. data/lib/tikkie/api/clients/refunds.rb +20 -0
  16. data/lib/tikkie/api/clients/sandbox_apps.rb +15 -0
  17. data/lib/tikkie/api/configuration.rb +8 -47
  18. data/lib/tikkie/api/exception.rb +28 -8
  19. data/lib/tikkie/api/request.rb +51 -27
  20. data/lib/tikkie/api/resources/base.rb +66 -0
  21. data/lib/tikkie/api/{responses → resources}/error.rb +11 -9
  22. data/lib/tikkie/api/resources/list.rb +52 -0
  23. data/lib/tikkie/api/resources/payment.rb +68 -0
  24. data/lib/tikkie/api/resources/payment_request.rb +97 -0
  25. data/lib/tikkie/api/resources/payment_requests.rb +40 -0
  26. data/lib/tikkie/api/resources/payment_requests_subscription.rb +24 -0
  27. data/lib/tikkie/api/resources/payments.rb +48 -0
  28. data/lib/tikkie/api/resources/refund.rb +71 -0
  29. data/lib/tikkie/api/resources/sandbox_app.rb +20 -0
  30. data/lib/tikkie/api/response.rb +64 -0
  31. data/lib/tikkie/api/v1/access_token.rb +21 -0
  32. data/lib/tikkie/api/v1/authentication.rb +67 -0
  33. data/lib/tikkie/api/v1/client.rb +26 -0
  34. data/lib/tikkie/api/v1/configuration.rb +64 -0
  35. data/lib/tikkie/api/v1/exception.rb +24 -0
  36. data/lib/tikkie/api/v1/request.rb +59 -0
  37. data/lib/tikkie/api/v1/requests/payment_requests.rb +59 -0
  38. data/lib/tikkie/api/v1/requests/platforms.rb +34 -0
  39. data/lib/tikkie/api/v1/requests/users.rb +33 -0
  40. data/lib/tikkie/api/v1/responses/bank_account.rb +24 -0
  41. data/lib/tikkie/api/v1/responses/base.rb +69 -0
  42. data/lib/tikkie/api/v1/responses/error.rb +36 -0
  43. data/lib/tikkie/api/v1/responses/pagination.rb +22 -0
  44. data/lib/tikkie/api/v1/responses/payment.rb +50 -0
  45. data/lib/tikkie/api/v1/responses/payment_request.rb +68 -0
  46. data/lib/tikkie/api/v1/responses/payment_request_created.rb +24 -0
  47. data/lib/tikkie/api/v1/responses/payment_requests.rb +44 -0
  48. data/lib/tikkie/api/v1/responses/platform.rb +46 -0
  49. data/lib/tikkie/api/v1/responses/platforms.rb +34 -0
  50. data/lib/tikkie/api/v1/responses/user.rb +43 -0
  51. data/lib/tikkie/api/v1/responses/users.rb +38 -0
  52. data/lib/tikkie/api/v1/types/payment_request_status.rb +17 -0
  53. data/lib/tikkie/api/v1/types/payment_status.rb +16 -0
  54. data/lib/tikkie/api/v1/types/platform_status.rb +14 -0
  55. data/lib/tikkie/api/v1/types/platform_usage.rb +14 -0
  56. data/lib/tikkie/api/v1/types/user_status.rb +14 -0
  57. data/lib/tikkie/api/version.rb +1 -1
  58. data/lib/tikkie/notification.rb +23 -0
  59. data/lib/tikkie/notifications/bundle_notification.rb +28 -0
  60. data/lib/tikkie/notifications/payment_notification.rb +32 -0
  61. data/lib/tikkie/notifications/refund_notification.rb +36 -0
  62. data/tikkie-api.gemspec +3 -2
  63. metadata +69 -43
  64. data/lib/tikkie/api/access_token.rb +0 -19
  65. data/lib/tikkie/api/authentication.rb +0 -65
  66. data/lib/tikkie/api/requests/payment_requests.rb +0 -57
  67. data/lib/tikkie/api/requests/platforms.rb +0 -32
  68. data/lib/tikkie/api/requests/users.rb +0 -31
  69. data/lib/tikkie/api/responses/bank_account.rb +0 -22
  70. data/lib/tikkie/api/responses/base.rb +0 -67
  71. data/lib/tikkie/api/responses/pagination.rb +0 -20
  72. data/lib/tikkie/api/responses/payment.rb +0 -48
  73. data/lib/tikkie/api/responses/payment_request.rb +0 -66
  74. data/lib/tikkie/api/responses/payment_request_created.rb +0 -22
  75. data/lib/tikkie/api/responses/payment_requests.rb +0 -42
  76. data/lib/tikkie/api/responses/platform.rb +0 -44
  77. data/lib/tikkie/api/responses/platforms.rb +0 -32
  78. data/lib/tikkie/api/responses/user.rb +0 -41
  79. data/lib/tikkie/api/responses/users.rb +0 -36
  80. data/lib/tikkie/api/types/payment_request_status.rb +0 -15
  81. data/lib/tikkie/api/types/payment_status.rb +0 -14
  82. data/lib/tikkie/api/types/platform_status.rb +0 -12
  83. data/lib/tikkie/api/types/platform_usage.rb +0 -12
  84. data/lib/tikkie/api/types/user_status.rb +0 -12
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Responses
7
+ # Response when requesting an user.
8
+ class User < Base
9
+ def user_token
10
+ data[:userToken]
11
+ end
12
+
13
+ def name
14
+ data[:name]
15
+ end
16
+
17
+ # see UserStatus
18
+ def status
19
+ data[:status]
20
+ end
21
+
22
+ def active?
23
+ status == Tikkie::Api::V1::Types::UserStatus::ACTIVE
24
+ end
25
+
26
+ def bank_accounts
27
+ @bank_accounts ||= begin
28
+ bank_accounts = []
29
+
30
+ if data[:bankAccounts]
31
+ data[:bankAccounts].each do |data|
32
+ bank_accounts << Tikkie::Api::V1::Responses::BankAccount.new(data)
33
+ end
34
+ end
35
+
36
+ bank_accounts
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Responses
7
+ # Response when requesting users (list).
8
+ class Users < Base
9
+ include Enumerable
10
+
11
+ def initialize(response)
12
+ super(response)
13
+ end
14
+
15
+ def each(&block)
16
+ users.each(&block)
17
+ end
18
+
19
+ private
20
+
21
+ def users
22
+ @users ||= begin
23
+ users = []
24
+
25
+ unless error?
26
+ data.each do |user|
27
+ users << Tikkie::Api::V1::Responses::User.new(user)
28
+ end
29
+ end
30
+
31
+ users
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Types
7
+ module PaymentRequestStatus
8
+ OPEN = "OPEN"
9
+ CLOSED = "CLOSED"
10
+ EXPIRED = "EXPIRED"
11
+ MAX_YIELD_REACHED = "MAX_YIELD_REACHED"
12
+ MAX_SUCCESSFUL_PAYMENTS_REACHED = "MAX_SUCCESSFUL_PAYMENTS_REACHED"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Types
7
+ module PaymentStatus
8
+ NEW = "NEW"
9
+ PENDING = "PENDING"
10
+ PAID = "PAID"
11
+ NOT_PAID = "NOT_PAID"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Types
7
+ module PlatformStatus
8
+ ACTIVE = "ACTIVE"
9
+ INACTIVE = "INACTIVE"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Types
7
+ module PlatformUsage
8
+ FOR_MYSELF = "PAYMENT_REQUEST_FOR_MYSELF"
9
+ FOR_OTHERS = "PAYMENT_REQUEST_FOR_OTHERS"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Api
5
+ module V1
6
+ module Types
7
+ module UserStatus
8
+ ACTIVE = "ACTIVE"
9
+ INACTIVE = "INACTIVE"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tikkie
4
4
  module Api
5
- VERSION = "0.2.2"
5
+ VERSION = "2.0.0"
6
6
  end
7
7
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "tikkie/notifications/bundle_notification"
4
+ require "tikkie/notifications/payment_notification"
5
+ require "tikkie/notifications/refund_notification"
6
+
7
+ module Tikkie
8
+ # Parses the payload for a Notification.
9
+ module Notification
10
+ module_function
11
+
12
+ def parse(body)
13
+ notification = JSON.parse(body, symbolize_names: true)
14
+ notification_type = notification[:notificationType]&.capitalize
15
+ return nil if notification_type.nil? || notification_type !~ /[a-z]+/i
16
+
17
+ klass = Object.const_get("Tikkie::Notifications::#{notification_type}Notification")
18
+ klass.new(notification)
19
+ rescue JSON::ParserError, NameError
20
+ nil
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Notifications
5
+ # Bundle notification.
6
+ class BundleNotification
7
+ NOTIFICATION_TYPE = "BUNDLE"
8
+
9
+ attr_reader :body
10
+
11
+ def initialize(body)
12
+ @body = body
13
+ end
14
+
15
+ def subscription_id
16
+ body[:subscriptionId]
17
+ end
18
+
19
+ def notification_type
20
+ body[:notificationType]
21
+ end
22
+
23
+ def bundle_id
24
+ body[:bundleId]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Notifications
5
+ # Payment notification.
6
+ class PaymentNotification
7
+ NOTIFICATION_TYPE = "PAYMENT"
8
+
9
+ attr_reader :body
10
+
11
+ def initialize(body)
12
+ @body = body
13
+ end
14
+
15
+ def subscription_id
16
+ body[:subscriptionId]
17
+ end
18
+
19
+ def notification_type
20
+ body[:notificationType]
21
+ end
22
+
23
+ def payment_request_token
24
+ body[:paymentRequestToken]
25
+ end
26
+
27
+ def payment_token
28
+ body[:paymentToken]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tikkie
4
+ module Notifications
5
+ # Refund notification.
6
+ class RefundNotification
7
+ NOTIFICATION_TYPE = "REFUND"
8
+
9
+ attr_reader :body
10
+
11
+ def initialize(body)
12
+ @body = body
13
+ end
14
+
15
+ def subscription_id
16
+ body[:subscriptionId]
17
+ end
18
+
19
+ def notification_type
20
+ body[:notificationType]
21
+ end
22
+
23
+ def payment_request_token
24
+ body[:paymentRequestToken]
25
+ end
26
+
27
+ def payment_token
28
+ body[:paymentToken]
29
+ end
30
+
31
+ def refund_token
32
+ body[:refundToken]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_dependency "jwt", ">= 1.0"
24
+ spec.required_ruby_version = ">= 2.4.0"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "jwt", ">= 1.0"
28
+ spec.add_development_dependency "rake", "~> 13.0"
28
29
  spec.add_development_dependency "rspec", "~> 3.0"
29
30
  spec.add_development_dependency "timecop", "~> 0.9"
30
31
  spec.add_development_dependency "webmock", "~> 2.3"
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tikkie-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaa BV
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: jwt
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
19
+ version: '1.16'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: jwt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +94,7 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.3'
97
- description:
97
+ description:
98
98
  email:
99
99
  - support@kentaa.nl
100
100
  executables: []
@@ -113,39 +113,65 @@ files:
113
113
  - bin/console
114
114
  - bin/setup
115
115
  - lib/tikkie/api.rb
116
- - lib/tikkie/api/access_token.rb
117
- - lib/tikkie/api/authentication.rb
116
+ - lib/tikkie/api/amount.rb
118
117
  - lib/tikkie/api/client.rb
118
+ - lib/tikkie/api/clients/base.rb
119
+ - lib/tikkie/api/clients/payment_requests.rb
120
+ - lib/tikkie/api/clients/payment_requests_subscription.rb
121
+ - lib/tikkie/api/clients/payments.rb
122
+ - lib/tikkie/api/clients/refunds.rb
123
+ - lib/tikkie/api/clients/sandbox_apps.rb
119
124
  - lib/tikkie/api/configuration.rb
120
125
  - lib/tikkie/api/exception.rb
121
126
  - lib/tikkie/api/request.rb
122
- - lib/tikkie/api/requests/payment_requests.rb
123
- - lib/tikkie/api/requests/platforms.rb
124
- - lib/tikkie/api/requests/users.rb
125
- - lib/tikkie/api/responses/bank_account.rb
126
- - lib/tikkie/api/responses/base.rb
127
- - lib/tikkie/api/responses/error.rb
128
- - lib/tikkie/api/responses/pagination.rb
129
- - lib/tikkie/api/responses/payment.rb
130
- - lib/tikkie/api/responses/payment_request.rb
131
- - lib/tikkie/api/responses/payment_request_created.rb
132
- - lib/tikkie/api/responses/payment_requests.rb
133
- - lib/tikkie/api/responses/platform.rb
134
- - lib/tikkie/api/responses/platforms.rb
135
- - lib/tikkie/api/responses/user.rb
136
- - lib/tikkie/api/responses/users.rb
137
- - lib/tikkie/api/types/payment_request_status.rb
138
- - lib/tikkie/api/types/payment_status.rb
139
- - lib/tikkie/api/types/platform_status.rb
140
- - lib/tikkie/api/types/platform_usage.rb
141
- - lib/tikkie/api/types/user_status.rb
127
+ - lib/tikkie/api/resources/base.rb
128
+ - lib/tikkie/api/resources/error.rb
129
+ - lib/tikkie/api/resources/list.rb
130
+ - lib/tikkie/api/resources/payment.rb
131
+ - lib/tikkie/api/resources/payment_request.rb
132
+ - lib/tikkie/api/resources/payment_requests.rb
133
+ - lib/tikkie/api/resources/payment_requests_subscription.rb
134
+ - lib/tikkie/api/resources/payments.rb
135
+ - lib/tikkie/api/resources/refund.rb
136
+ - lib/tikkie/api/resources/sandbox_app.rb
137
+ - lib/tikkie/api/response.rb
138
+ - lib/tikkie/api/v1/access_token.rb
139
+ - lib/tikkie/api/v1/authentication.rb
140
+ - lib/tikkie/api/v1/client.rb
141
+ - lib/tikkie/api/v1/configuration.rb
142
+ - lib/tikkie/api/v1/exception.rb
143
+ - lib/tikkie/api/v1/request.rb
144
+ - lib/tikkie/api/v1/requests/payment_requests.rb
145
+ - lib/tikkie/api/v1/requests/platforms.rb
146
+ - lib/tikkie/api/v1/requests/users.rb
147
+ - lib/tikkie/api/v1/responses/bank_account.rb
148
+ - lib/tikkie/api/v1/responses/base.rb
149
+ - lib/tikkie/api/v1/responses/error.rb
150
+ - lib/tikkie/api/v1/responses/pagination.rb
151
+ - lib/tikkie/api/v1/responses/payment.rb
152
+ - lib/tikkie/api/v1/responses/payment_request.rb
153
+ - lib/tikkie/api/v1/responses/payment_request_created.rb
154
+ - lib/tikkie/api/v1/responses/payment_requests.rb
155
+ - lib/tikkie/api/v1/responses/platform.rb
156
+ - lib/tikkie/api/v1/responses/platforms.rb
157
+ - lib/tikkie/api/v1/responses/user.rb
158
+ - lib/tikkie/api/v1/responses/users.rb
159
+ - lib/tikkie/api/v1/types/payment_request_status.rb
160
+ - lib/tikkie/api/v1/types/payment_status.rb
161
+ - lib/tikkie/api/v1/types/platform_status.rb
162
+ - lib/tikkie/api/v1/types/platform_usage.rb
163
+ - lib/tikkie/api/v1/types/user_status.rb
142
164
  - lib/tikkie/api/version.rb
165
+ - lib/tikkie/notification.rb
166
+ - lib/tikkie/notifications/bundle_notification.rb
167
+ - lib/tikkie/notifications/payment_notification.rb
168
+ - lib/tikkie/notifications/refund_notification.rb
143
169
  - tikkie-api.gemspec
144
170
  homepage: https://github.com/KentaaNL/tikkie-api
145
171
  licenses:
146
172
  - MIT
147
173
  metadata: {}
148
- post_install_message:
174
+ post_install_message:
149
175
  rdoc_options: []
150
176
  require_paths:
151
177
  - lib
@@ -153,15 +179,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
179
  requirements:
154
180
  - - ">="
155
181
  - !ruby/object:Gem::Version
156
- version: '0'
182
+ version: 2.4.0
157
183
  required_rubygems_version: !ruby/object:Gem::Requirement
158
184
  requirements:
159
185
  - - ">="
160
186
  - !ruby/object:Gem::Version
161
187
  version: '0'
162
188
  requirements: []
163
- rubygems_version: 3.0.1
164
- signing_key:
189
+ rubygems_version: 3.0.8
190
+ signing_key:
165
191
  specification_version: 4
166
192
  summary: Ruby library for communicating with the Tikkie API
167
193
  test_files: []