tarpon 0.2.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43d32ae8222984c5d2c3bda9e1180af14df41282df57877738e54f7b527613ee
4
- data.tar.gz: 970daff511109f860752b86d8a5455f213f62a39d58dcdecbad7a90b08d5bab0
3
+ metadata.gz: 9ca9c5d848e253fa9a464b757e8c8bd6457402233a87ef3c0fad624deb51323d
4
+ data.tar.gz: e4a58e820eafd48096f00aee5954187427fea273374d8abeb550185c6f95784e
5
5
  SHA512:
6
- metadata.gz: 4b7afdaf330f8c8045fc50ec53218943ddd370afd655dcb4d0c9899882210a5970d6b21f217755fdaeabc9d475e986064240fd3d09fc35efe1d00e1c935a9a3a
7
- data.tar.gz: f318b1b22b050f49bd57abb41db3d9ca96e90f3697d3166355402fa64922cf665b1b4e431291c0c4e24e402de85f47b4514b172989338a9ced6d069f48a78110
6
+ metadata.gz: 07c5e934acf193a1811f6b2491381e5a6728756a00f46c2f899ecb0a975a39156f3d9df6ee76ba720b91a1a76a0a3eb7a22314af59e2f9d7fd96e33b7d782314
7
+ data.tar.gz: ba78c1e53736671041b5768d44c624747ed598d06745589c2449c0d5c18566669b3bf9d271f050ea737a55d095b1444f43ff06511d2137061c6dfb3813a9a360
@@ -17,6 +17,10 @@ module Tarpon
17
17
  def expires_date
18
18
  Time.iso8601(@raw[:expires_date])
19
19
  end
20
+
21
+ def purchase_date
22
+ Time.iso8601(@raw[:purchase_date])
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -17,8 +17,8 @@ module Tarpon
17
17
  @entitlements.select(&:active?)
18
18
  end
19
19
 
20
- def each
21
- @entitlements.each { |e| yield e }
20
+ def each(&block)
21
+ @entitlements.each(&block)
22
22
  end
23
23
  end
24
24
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tarpon
4
+ module Entity
5
+ Package = Struct.new(:identifier, :platform_identifier)
6
+ class Offering
7
+ attr_reader :identifier, :description, :packages
8
+
9
+ def initialize(identifier:, description:, packages:, **)
10
+ @identifier = identifier
11
+ @description = description
12
+ @packages = packages.map do |package|
13
+ Package.new(package[:identifier], package[:platform_product_identifier])
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tarpon/entity/offering'
4
+
5
+ module Tarpon
6
+ module Entity
7
+ class Offerings
8
+ include Enumerable
9
+
10
+ attr_reader :current_offering_id, :offerings
11
+
12
+ def initialize(current_offering_id:, offerings:, **)
13
+ @current_offering_id = current_offering_id
14
+ @offerings = offerings.each_with_object({}) do |offering, map|
15
+ map[offering[:identifier].to_sym] = Tarpon::Entity::Offering.new(**offering)
16
+ end
17
+ end
18
+
19
+ def each(&block)
20
+ @offerings.each(&block)
21
+ end
22
+
23
+ def [](identifier)
24
+ @offerings[identifier.to_sym]
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/tarpon/errors.rb CHANGED
@@ -6,4 +6,5 @@ module Tarpon
6
6
  class InvalidCredentialsError < Error; end
7
7
  class ServerError < Error; end
8
8
  class NotFoundError < Error; end
9
+ class TooManyRequests < Error; end
9
10
  end
@@ -18,7 +18,7 @@ module Tarpon
18
18
  .auth("Bearer #{api_key(key)}")
19
19
  .headers(headers.merge(DEFAULT_HEADERS))
20
20
  .send(method, "#{Client.base_uri}#{path}", json: body&.compact)
21
- .yield_self { |http_response| handle_response(http_response) }
21
+ .then { |http_response| handle_response(http_response) }
22
22
  rescue HTTP::TimeoutError => e
23
23
  raise Tarpon::TimeoutError, e
24
24
  end
@@ -56,6 +56,8 @@ module Tarpon
56
56
  raise Tarpon::ServerError, 'RevenueCat failed to fulfill the request'
57
57
  when 404
58
58
  raise Tarpon::NotFoundError
59
+ when 429
60
+ raise Tarpon::TooManyRequests
59
61
  else
60
62
  create_response(http_response)
61
63
  end
@@ -5,6 +5,7 @@ module Tarpon
5
5
  class Subscriber
6
6
  class Entitlement < Base
7
7
  def initialize(subscriber_path:, entitlement_identifier:)
8
+ super()
8
9
  @subscriber_path = subscriber_path
9
10
  @entitlement_identifier = entitlement_identifier
10
11
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tarpon/entity/offerings'
4
+
5
+ module Tarpon
6
+ module Request
7
+ class Subscriber
8
+ class Offering < Base
9
+ def initialize(subscriber_path:)
10
+ super()
11
+ @subscriber_path = subscriber_path
12
+ end
13
+
14
+ def list(platform)
15
+ response = perform(method: :get, path: path.to_s, headers: { 'x-platform': platform.to_s }, key: :public)
16
+ return response unless response.success?
17
+
18
+ Tarpon::Entity::Offerings.new(**response.raw)
19
+ end
20
+
21
+ private
22
+
23
+ def path
24
+ "#{@subscriber_path}/offerings"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -5,6 +5,7 @@ module Tarpon
5
5
  class Subscriber
6
6
  class Subscription < Base
7
7
  def initialize(subscriber_path:, product_id:)
8
+ super()
8
9
  @subscriber_path = subscriber_path
9
10
  @product_id = product_id
10
11
  end
@@ -4,14 +4,13 @@ module Tarpon
4
4
  module Request
5
5
  class Subscriber < Base
6
6
  def initialize(app_user_id:)
7
+ super()
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)
@@ -21,6 +20,10 @@ module Tarpon
21
20
  self.class::Entitlement.new(subscriber_path: path, entitlement_identifier: entitlement_identifier)
22
21
  end
23
22
 
23
+ def offerings
24
+ self.class::Offering.new(subscriber_path: path)
25
+ end
26
+
24
27
  def subscriptions(product_id)
25
28
  self.class::Subscription.new(subscriber_path: path, product_id: product_id)
26
29
  end
@@ -7,7 +7,7 @@ module Tarpon
7
7
  def initialize(status, attributes)
8
8
  @status = status
9
9
  @raw = attributes
10
- @subscriber = @raw[:subscriber].nil? ? nil : Entity::Subscriber.new(@raw[:subscriber])
10
+ @subscriber = @raw[:subscriber] && Entity::Subscriber.new(@raw[:subscriber])
11
11
  end
12
12
 
13
13
  def message
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tarpon
4
- VERSION = '0.2.1'
4
+ VERSION = '0.4.0'
5
5
  end
data/lib/tarpon.rb CHANGED
@@ -9,6 +9,7 @@ require 'tarpon/request/base'
9
9
  require 'tarpon/request/subscriber'
10
10
  require 'tarpon/request/subscriber/entitlement'
11
11
  require 'tarpon/request/subscriber/subscription'
12
+ require 'tarpon/request/subscriber/offering'
12
13
  require 'tarpon/request/receipt'
13
14
  require 'tarpon/response'
14
15
  require 'tarpon/version'
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.2.1
4
+ version: 0.4.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: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2022-06-02 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.3'
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.3'
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: '5.1'
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: '5.1'
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: '10.0'
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: '10.0'
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.0'
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.0'
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: '0.80'
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: '0.80'
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.8'
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.8'
96
+ version: '3.14'
111
97
  description: A Ruby interface to RevenueCat REST API
112
98
  email:
113
99
  - igor.belo@fishbrain.com
@@ -120,12 +106,15 @@ files:
120
106
  - lib/tarpon/configuration.rb
121
107
  - lib/tarpon/entity/entitlement.rb
122
108
  - lib/tarpon/entity/entitlement_list.rb
109
+ - lib/tarpon/entity/offering.rb
110
+ - lib/tarpon/entity/offerings.rb
123
111
  - lib/tarpon/entity/subscriber.rb
124
112
  - lib/tarpon/errors.rb
125
113
  - lib/tarpon/request/base.rb
126
114
  - lib/tarpon/request/receipt.rb
127
115
  - lib/tarpon/request/subscriber.rb
128
116
  - lib/tarpon/request/subscriber/entitlement.rb
117
+ - lib/tarpon/request/subscriber/offering.rb
129
118
  - lib/tarpon/request/subscriber/subscription.rb
130
119
  - lib/tarpon/response.rb
131
120
  - lib/tarpon/version.rb
@@ -136,7 +125,8 @@ metadata:
136
125
  homepage_uri: https://github.com/fishbrain/tarpon
137
126
  source_code_uri: https://github.com/fishbrain/tarpon.git
138
127
  changelog_uri: https://github.com/fishbrain/tarpon/blob/master/CHANGELOG.md
139
- post_install_message:
128
+ rubygems_mfa_required: 'true'
129
+ post_install_message:
140
130
  rdoc_options: []
141
131
  require_paths:
142
132
  - lib
@@ -144,15 +134,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
134
  requirements:
145
135
  - - ">="
146
136
  - !ruby/object:Gem::Version
147
- version: '0'
137
+ version: '2.7'
148
138
  required_rubygems_version: !ruby/object:Gem::Requirement
149
139
  requirements:
150
140
  - - ">="
151
141
  - !ruby/object:Gem::Version
152
142
  version: '0'
153
143
  requirements: []
154
- rubygems_version: 3.0.3
155
- signing_key:
144
+ rubygems_version: 3.3.12
145
+ signing_key:
156
146
  specification_version: 4
157
147
  summary: A Ruby interface to RevenueCat REST API
158
148
  test_files: []