tarpon 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tarpon/client.rb +21 -7
- data/lib/tarpon/configuration.rb +5 -1
- data/lib/tarpon/entity/entitlement_list.rb +2 -2
- data/lib/tarpon/entity/offerings.rb +3 -3
- data/lib/tarpon/request/base.rb +10 -4
- data/lib/tarpon/request/subscriber/entitlement.rb +2 -1
- data/lib/tarpon/request/subscriber/offering.rb +3 -2
- data/lib/tarpon/request/subscriber/subscription.rb +2 -1
- data/lib/tarpon/request/subscriber.rb +10 -7
- data/lib/tarpon/response.rb +1 -1
- data/lib/tarpon/version.rb +1 -1
- metadata +20 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d6acb3ebc1ea690eba860bd056c0de1e1bd225d82d27996c281415e82e8deca
|
4
|
+
data.tar.gz: e350303887989f6dd361e6d8a4517dc421be6ca29589120f677980b4ba046b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 542d5d0781ff979ce7c51c5df96e54afe89830aa8f1570dc76b6326c7cd07519764d4d95b197cc66a6c9de1504093dcfe6819a89c3c97a3c011f3341da42d6e1
|
7
|
+
data.tar.gz: 79d50fa993c8d48c648bc81a7d9ef793278459445095b6703019d97dc8269d956afd073e15e7b8553303fe297672ec8b0e4cd3053fd5ec1993fce29e6bc3c754
|
data/lib/tarpon/client.rb
CHANGED
@@ -1,19 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'forwardable'
|
3
4
|
require 'tarpon/configuration'
|
4
5
|
|
5
6
|
module Tarpon
|
6
7
|
class Client
|
7
|
-
|
8
|
+
include Configuration
|
9
|
+
|
10
|
+
def self.default
|
11
|
+
@default ||= new
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(**config, &block)
|
15
|
+
config.each { |key, val| public_send("#{key}=", val) }
|
16
|
+
yield self if block
|
17
|
+
end
|
8
18
|
|
9
19
|
class << self
|
10
|
-
|
11
|
-
|
12
|
-
|
20
|
+
extend Forwardable
|
21
|
+
def_delegators :default, *Configuration.public_instance_methods(true)
|
22
|
+
def_delegators :default, :subscriber, :receipt
|
23
|
+
end
|
24
|
+
|
25
|
+
def subscriber(app_user_id)
|
26
|
+
Request::Subscriber.new(app_user_id: app_user_id, client: self)
|
27
|
+
end
|
13
28
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
29
|
+
def receipt
|
30
|
+
Request::Receipt.new(client: self)
|
17
31
|
end
|
18
32
|
end
|
19
33
|
end
|
data/lib/tarpon/configuration.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Tarpon
|
4
4
|
module Configuration
|
5
5
|
attr_accessor :public_api_key, :secret_api_key
|
6
|
-
attr_writer :base_uri, :timeout
|
6
|
+
attr_writer :base_uri, :timeout, :http_middleware
|
7
7
|
|
8
8
|
def configure
|
9
9
|
yield self
|
@@ -16,5 +16,9 @@ module Tarpon
|
|
16
16
|
def timeout
|
17
17
|
@timeout || 5
|
18
18
|
end
|
19
|
+
|
20
|
+
def http_middleware
|
21
|
+
@http_middleware ||= ->(http_client) { http_client }
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
@@ -12,12 +12,12 @@ module Tarpon
|
|
12
12
|
def initialize(current_offering_id:, offerings:, **)
|
13
13
|
@current_offering_id = current_offering_id
|
14
14
|
@offerings = offerings.each_with_object({}) do |offering, map|
|
15
|
-
map[offering[:identifier].to_sym] = Tarpon::Entity::Offering.new(offering)
|
15
|
+
map[offering[:identifier].to_sym] = Tarpon::Entity::Offering.new(**offering)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def each
|
20
|
-
@offerings.each
|
19
|
+
def each(&block)
|
20
|
+
@offerings.each(&block)
|
21
21
|
end
|
22
22
|
|
23
23
|
def [](identifier)
|
data/lib/tarpon/request/base.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'http'
|
4
|
+
require 'tarpon/client'
|
4
5
|
|
5
6
|
module Tarpon
|
6
7
|
module Request
|
@@ -10,15 +11,20 @@ module Tarpon
|
|
10
11
|
content_type: 'application/json'
|
11
12
|
}.freeze
|
12
13
|
|
14
|
+
def initialize(client: Client.default)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
13
18
|
protected
|
14
19
|
|
15
20
|
def perform(method:, path:, key:, headers: {}, body: nil)
|
16
21
|
HTTP
|
17
|
-
.timeout(
|
22
|
+
.timeout(@client.timeout)
|
23
|
+
.then { |http_client| @client.http_middleware.call(http_client) }
|
18
24
|
.auth("Bearer #{api_key(key)}")
|
19
25
|
.headers(headers.merge(DEFAULT_HEADERS))
|
20
|
-
.send(method, "#{
|
21
|
-
.
|
26
|
+
.send(method, "#{@client.base_uri}#{path}", json: body&.compact)
|
27
|
+
.then { |http_response| handle_response(http_response) }
|
22
28
|
rescue HTTP::TimeoutError => e
|
23
29
|
raise Tarpon::TimeoutError, e
|
24
30
|
end
|
@@ -26,7 +32,7 @@ module Tarpon
|
|
26
32
|
private
|
27
33
|
|
28
34
|
def api_key(type)
|
29
|
-
|
35
|
+
@client.send("#{type}_api_key")
|
30
36
|
end
|
31
37
|
|
32
38
|
def parse_body(http_response)
|
@@ -4,7 +4,8 @@ module Tarpon
|
|
4
4
|
module Request
|
5
5
|
class Subscriber
|
6
6
|
class Entitlement < Base
|
7
|
-
def initialize(subscriber_path:, entitlement_identifier
|
7
|
+
def initialize(subscriber_path:, entitlement_identifier:, **opts)
|
8
|
+
super(**opts)
|
8
9
|
@subscriber_path = subscriber_path
|
9
10
|
@entitlement_identifier = entitlement_identifier
|
10
11
|
end
|
@@ -6,7 +6,8 @@ module Tarpon
|
|
6
6
|
module Request
|
7
7
|
class Subscriber
|
8
8
|
class Offering < Base
|
9
|
-
def initialize(subscriber_path
|
9
|
+
def initialize(subscriber_path:, **opts)
|
10
|
+
super(**opts)
|
10
11
|
@subscriber_path = subscriber_path
|
11
12
|
end
|
12
13
|
|
@@ -14,7 +15,7 @@ module Tarpon
|
|
14
15
|
response = perform(method: :get, path: path.to_s, headers: { 'x-platform': platform.to_s }, key: :public)
|
15
16
|
return response unless response.success?
|
16
17
|
|
17
|
-
Tarpon::Entity::Offerings.new(response.raw)
|
18
|
+
Tarpon::Entity::Offerings.new(**response.raw)
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -4,7 +4,8 @@ module Tarpon
|
|
4
4
|
module Request
|
5
5
|
class Subscriber
|
6
6
|
class Subscription < Base
|
7
|
-
def initialize(subscriber_path:, product_id
|
7
|
+
def initialize(subscriber_path:, product_id:, **opts)
|
8
|
+
super(**opts)
|
8
9
|
@subscriber_path = subscriber_path
|
9
10
|
@product_id = product_id
|
10
11
|
end
|
@@ -3,30 +3,33 @@
|
|
3
3
|
module Tarpon
|
4
4
|
module Request
|
5
5
|
class Subscriber < Base
|
6
|
-
def initialize(app_user_id
|
6
|
+
def initialize(app_user_id:, **opts)
|
7
|
+
super(**opts)
|
7
8
|
@app_user_id = app_user_id
|
8
9
|
end
|
9
10
|
|
10
|
-
# rubocop:disable Naming/AccessorMethodName
|
11
|
-
def get_or_create
|
11
|
+
def get_or_create # rubocop:disable Naming/AccessorMethodName
|
12
12
|
perform(method: :get, path: path, key: :public)
|
13
13
|
end
|
14
|
-
# rubocop:enable Naming/AccessorMethodName
|
15
14
|
|
16
15
|
def delete
|
17
16
|
perform(method: :delete, path: path, key: :secret)
|
18
17
|
end
|
19
18
|
|
20
19
|
def entitlements(entitlement_identifier)
|
21
|
-
self.class::Entitlement.new(
|
20
|
+
self.class::Entitlement.new(
|
21
|
+
subscriber_path: path,
|
22
|
+
entitlement_identifier: entitlement_identifier,
|
23
|
+
client: @client
|
24
|
+
)
|
22
25
|
end
|
23
26
|
|
24
27
|
def offerings
|
25
|
-
self.class::Offering.new(subscriber_path: path)
|
28
|
+
self.class::Offering.new(subscriber_path: path, client: @client)
|
26
29
|
end
|
27
30
|
|
28
31
|
def subscriptions(product_id)
|
29
|
-
self.class::Subscription.new(subscriber_path: path, product_id: product_id)
|
32
|
+
self.class::Subscription.new(subscriber_path: path, product_id: product_id, client: @client)
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
data/lib/tarpon/response.rb
CHANGED
@@ -7,7 +7,7 @@ module Tarpon
|
|
7
7
|
def initialize(status, attributes)
|
8
8
|
@status = status
|
9
9
|
@raw = attributes
|
10
|
-
@subscriber = @raw[:subscriber]
|
10
|
+
@subscriber = @raw[:subscriber] && Entity::Subscriber.new(@raw[:subscriber])
|
11
11
|
end
|
12
12
|
|
13
13
|
def message
|
data/lib/tarpon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tarpon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Belo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -16,98 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.4'
|
20
20
|
type: :runtime
|
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: '4.
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.0'
|
26
|
+
version: '4.4'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: factory_bot
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '6.2'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
40
|
+
version: '6.2'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '13.0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '13.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
61
|
+
version: '3.11'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
68
|
+
version: '3.11'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rubocop
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '1.29'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '1.29'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
89
|
+
version: '3.14'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3.
|
96
|
+
version: '3.14'
|
111
97
|
description: A Ruby interface to RevenueCat REST API
|
112
98
|
email:
|
113
99
|
- igor.belo@fishbrain.com
|
@@ -139,7 +125,8 @@ metadata:
|
|
139
125
|
homepage_uri: https://github.com/fishbrain/tarpon
|
140
126
|
source_code_uri: https://github.com/fishbrain/tarpon.git
|
141
127
|
changelog_uri: https://github.com/fishbrain/tarpon/blob/master/CHANGELOG.md
|
142
|
-
|
128
|
+
rubygems_mfa_required: 'true'
|
129
|
+
post_install_message:
|
143
130
|
rdoc_options: []
|
144
131
|
require_paths:
|
145
132
|
- lib
|
@@ -147,15 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
134
|
requirements:
|
148
135
|
- - ">="
|
149
136
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
137
|
+
version: '2.7'
|
151
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
139
|
requirements:
|
153
140
|
- - ">="
|
154
141
|
- !ruby/object:Gem::Version
|
155
142
|
version: '0'
|
156
143
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
144
|
+
rubygems_version: 3.3.7
|
145
|
+
signing_key:
|
159
146
|
specification_version: 4
|
160
147
|
summary: A Ruby interface to RevenueCat REST API
|
161
148
|
test_files: []
|