tarpon 0.2.1 → 0.3.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: fb8e9e1ad34c8febb6eb35177f3978f6053d520ca4c09b03227c8b73b8b3522c
4
+ data.tar.gz: 75672ac651fafdc0f64e3e8813fab2a69d78601ea4fc5426873968ea49ff66af
5
5
  SHA512:
6
- metadata.gz: 4b7afdaf330f8c8045fc50ec53218943ddd370afd655dcb4d0c9899882210a5970d6b21f217755fdaeabc9d475e986064240fd3d09fc35efe1d00e1c935a9a3a
7
- data.tar.gz: f318b1b22b050f49bd57abb41db3d9ca96e90f3697d3166355402fa64922cf665b1b4e431291c0c4e24e402de85f47b4514b172989338a9ced6d069f48a78110
6
+ metadata.gz: 47fa9a6e62859ae6dceea4dc21e50fc0ce076c30d704ecc3403a962fba8ba74ac71a9a69fe55555034471beb495b16dc5d4591d2a479abca6c2e8c23d4d593fb
7
+ data.tar.gz: e441f5e22f50cdd35b574e07aca3c40c31464b5a3440fcc476f1b674b35704b77b99f6c2e3f66d15c7a515728f642158bd1173ed9b8347daca6c777201ca4639
@@ -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'
@@ -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
20
+ @offerings.each { |o| yield o }
21
+ end
22
+
23
+ def [](identifier)
24
+ @offerings[identifier.to_sym]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -21,6 +21,10 @@ module Tarpon
21
21
  self.class::Entitlement.new(subscriber_path: path, entitlement_identifier: entitlement_identifier)
22
22
  end
23
23
 
24
+ def offerings
25
+ self.class::Offering.new(subscriber_path: path)
26
+ end
27
+
24
28
  def subscriptions(product_id)
25
29
  self.class::Subscription.new(subscriber_path: path, product_id: product_id)
26
30
  end
@@ -0,0 +1,28 @@
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
+ @subscriber_path = subscriber_path
11
+ end
12
+
13
+ def list(platform)
14
+ response = perform(method: :get, path: path.to_s, headers: { 'x-platform': platform.to_s }, key: :public)
15
+ return response unless response.success?
16
+
17
+ Tarpon::Entity::Offerings.new(response.raw)
18
+ end
19
+
20
+ private
21
+
22
+ def path
23
+ "#{@subscriber_path}/offerings"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tarpon
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Belo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -120,12 +120,15 @@ files:
120
120
  - lib/tarpon/configuration.rb
121
121
  - lib/tarpon/entity/entitlement.rb
122
122
  - lib/tarpon/entity/entitlement_list.rb
123
+ - lib/tarpon/entity/offering.rb
124
+ - lib/tarpon/entity/offerings.rb
123
125
  - lib/tarpon/entity/subscriber.rb
124
126
  - lib/tarpon/errors.rb
125
127
  - lib/tarpon/request/base.rb
126
128
  - lib/tarpon/request/receipt.rb
127
129
  - lib/tarpon/request/subscriber.rb
128
130
  - lib/tarpon/request/subscriber/entitlement.rb
131
+ - lib/tarpon/request/subscriber/offering.rb
129
132
  - lib/tarpon/request/subscriber/subscription.rb
130
133
  - lib/tarpon/response.rb
131
134
  - lib/tarpon/version.rb