app_store_connect 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -4
- data/app_store_connect.gemspec +1 -2
- data/lib/app_store_connect/client/authorization.rb +38 -0
- data/lib/app_store_connect/client/options.rb +41 -0
- data/lib/app_store_connect/client/registry.rb +15 -0
- data/lib/app_store_connect/client/usage.rb +27 -0
- data/lib/app_store_connect/client.rb +17 -44
- data/lib/app_store_connect/request.rb +5 -7
- data/lib/app_store_connect/schema/object.rb +14 -0
- data/lib/app_store_connect/schema/type.rb +3 -6
- data/lib/app_store_connect/schema/web_service_endpoint.rb +1 -1
- data/lib/app_store_connect/schema.rb +8 -4
- data/lib/app_store_connect/version.rb +1 -1
- data/lib/app_store_connect.rb +4 -1
- data/lib/config/schema.json +1 -0
- metadata +9 -26
- data/Rakefile +0 -8
- data/lib/app_store_connect/authorization.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a05ac5b04cfade9f4bd31173b13bc7ac094580f5f3bbb41f24a881bab79f49f0
|
4
|
+
data.tar.gz: 3407d48bc34490ab5f555ffe943962af3a83ab19b3a455d5aa0080fda40c9244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123b7f157a91802a23c04c0df89fdf490da6fa775c705baf3643ae47d88c113eacb3dc102fe1755396e9f38b31984ba62dcaf5031a497465c1361ce11c245e5c
|
7
|
+
data.tar.gz: 1ffa55020b42a3b55cb1a48e413eb89e5ec2851e3c457c70cec9538c6ccb2ccd26ff45c05074e4b0adf9b910f1c7ef19e86b7d9b678f859ef1b3149a1e46f7ea
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
app_store_connect (0.
|
5
|
-
activesupport
|
4
|
+
app_store_connect (0.14.0)
|
5
|
+
activesupport
|
6
6
|
jwt (>= 1.4, <= 2.2.1)
|
7
7
|
mixpanel-ruby (<= 2.2.0)
|
8
8
|
|
@@ -67,7 +67,6 @@ GEM
|
|
67
67
|
method_source (~> 0.9.0)
|
68
68
|
public_suffix (3.1.1)
|
69
69
|
rainbow (3.0.0)
|
70
|
-
rake (10.5.0)
|
71
70
|
rb-fsevent (0.10.3)
|
72
71
|
rb-inotify (0.10.0)
|
73
72
|
ffi (~> 1.0)
|
@@ -120,7 +119,6 @@ DEPENDENCIES
|
|
120
119
|
factory_bot (~> 5.0.2)
|
121
120
|
guard-rspec (~> 4.7.3)
|
122
121
|
pry (~> 0.12)
|
123
|
-
rake (~> 10.0)
|
124
122
|
rspec (~> 3.0)
|
125
123
|
rubocop (~> 0.71.0)
|
126
124
|
simplecov (~> 0.16.1)
|
data/app_store_connect.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'activesupport'
|
23
|
+
spec.add_runtime_dependency 'activesupport'
|
24
24
|
spec.add_runtime_dependency 'jwt', '>= 1.4', '<= 2.2.1'
|
25
25
|
spec.add_runtime_dependency 'mixpanel-ruby', '<= 2.2.0'
|
26
26
|
|
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'factory_bot', '~> 5.0.2'
|
29
29
|
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
30
30
|
spec.add_development_dependency 'pry', '~> 0.12'
|
31
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
32
31
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
32
|
spec.add_development_dependency 'rubocop', '~> 0.71.0'
|
34
33
|
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jwt'
|
4
|
+
|
5
|
+
module AppStoreConnect
|
6
|
+
class Client
|
7
|
+
class Authorization
|
8
|
+
OPTIONS = %i[key_id issuer_id private_key].freeze
|
9
|
+
|
10
|
+
AUDIENCE = 'appstoreconnect-v1'
|
11
|
+
ALGORITHM = 'ES256'
|
12
|
+
|
13
|
+
attr_reader(*OPTIONS)
|
14
|
+
|
15
|
+
def initialize(options)
|
16
|
+
@key_id = options.fetch(:key_id)
|
17
|
+
@issuer_id = options.fetch(:issuer_id)
|
18
|
+
@private_key = OpenSSL::PKey.read(options.fetch(:private_key))
|
19
|
+
end
|
20
|
+
|
21
|
+
def payload
|
22
|
+
{
|
23
|
+
exp: Time.now.to_i + 20 * 60,
|
24
|
+
iss: issuer_id,
|
25
|
+
aud: AUDIENCE
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def header_fields
|
30
|
+
{ kid: key_id }
|
31
|
+
end
|
32
|
+
|
33
|
+
def token
|
34
|
+
JWT.encode(payload, private_key, ALGORITHM, header_fields)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'delegate'
|
4
|
+
|
5
|
+
module AppStoreConnect
|
6
|
+
class Client
|
7
|
+
class Options < SimpleDelegator
|
8
|
+
attr_reader :kwargs, :config, :env
|
9
|
+
|
10
|
+
ENV_REGEXP = /APP_STORE_CONNECT_(?<suffix>[A-Z_]+)/.freeze
|
11
|
+
private_constant :ENV_REGEXP
|
12
|
+
|
13
|
+
def initialize(kwargs)
|
14
|
+
@kwargs = kwargs
|
15
|
+
@config = build_config
|
16
|
+
@env = build_env
|
17
|
+
options = @config.merge(kwargs.merge(@env))
|
18
|
+
|
19
|
+
super(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def build_config
|
25
|
+
AppStoreConnect.config.dup
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_env
|
29
|
+
{}.tap do |hash|
|
30
|
+
ENV.each do |key, value|
|
31
|
+
match = key.match(ENV_REGEXP)
|
32
|
+
|
33
|
+
next unless match
|
34
|
+
|
35
|
+
hash[match[:suffix].downcase.to_sym] = value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'delegate'
|
4
|
+
|
5
|
+
module AppStoreConnect
|
6
|
+
class Client
|
7
|
+
class Registry < SimpleDelegator
|
8
|
+
OPTIONS = %i[schema].freeze
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
super(options .fetch(:schema).web_service_endpoints.map { |s| [s.alias, s] }.to_h)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mixpanel-ruby'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
module AppStoreConnect
|
7
|
+
class Client
|
8
|
+
class Usage
|
9
|
+
OPTIONS = %i[analytics_enabled].freeze
|
10
|
+
|
11
|
+
MIXPANEL_PROJECT_TOKEN = '1213f2b88b9b10b13d321f4c67a55ca8'
|
12
|
+
private_constant :MIXPANEL_PROJECT_TOKEN
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
@enabled = options[:analytics_enabled].to_s == 'true'
|
16
|
+
@distinct_id = SecureRandom.uuid
|
17
|
+
@tracker = Mixpanel::Tracker.new(MIXPANEL_PROJECT_TOKEN)
|
18
|
+
end
|
19
|
+
|
20
|
+
def track
|
21
|
+
return false unless @enabled
|
22
|
+
|
23
|
+
@tracker.track(@distinct_id, 'usage')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,30 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/all'
|
4
|
-
require 'mixpanel-ruby'
|
5
|
-
require 'securerandom'
|
6
4
|
|
7
5
|
require 'app_store_connect/request'
|
8
|
-
require 'app_store_connect/authorization'
|
9
6
|
require 'app_store_connect/schema'
|
7
|
+
require 'app_store_connect/client/authorization'
|
8
|
+
require 'app_store_connect/client/options'
|
9
|
+
require 'app_store_connect/client/usage'
|
10
|
+
require 'app_store_connect/client/registry'
|
10
11
|
|
11
12
|
module AppStoreConnect
|
12
13
|
class Client
|
13
14
|
def initialize(**kwargs)
|
14
|
-
@options =
|
15
|
-
|
16
|
-
@authorization = Authorization.new(
|
17
|
-
|
18
|
-
key_id: @options[:key_id],
|
19
|
-
issuer_id: @options[:issuer_id]
|
20
|
-
)
|
21
|
-
@web_service_endpoints_by_alias ||= @options
|
22
|
-
.fetch(:schema)
|
23
|
-
.web_service_endpoints
|
24
|
-
.map { |s| [s.alias, s] }
|
25
|
-
.to_h
|
26
|
-
@distinct_id = SecureRandom.uuid
|
27
|
-
@tracker = Mixpanel::Tracker.new('1213f2b88b9b10b13d321f4c67a55ca8')
|
15
|
+
@options = Options.new(kwargs)
|
16
|
+
@usage = Usage.new(@options.slice(*Usage::OPTIONS))
|
17
|
+
@authorization = Authorization.new(@options.slice(*Authorization::OPTIONS))
|
18
|
+
@registry = Registry.new(@options.slice(*Registry::OPTIONS))
|
28
19
|
end
|
29
20
|
|
30
21
|
def respond_to_missing?(method_name, include_private = false)
|
@@ -39,8 +30,14 @@ module AppStoreConnect
|
|
39
30
|
call(web_service_endpoint, *kwargs)
|
40
31
|
end
|
41
32
|
|
33
|
+
# :nocov:
|
34
|
+
def inspect
|
35
|
+
"#<#{self.class.name}:#{object_id}>"
|
36
|
+
end
|
37
|
+
# :nocov:
|
38
|
+
|
42
39
|
def web_service_endpoint_aliases
|
43
|
-
@
|
40
|
+
@registry.keys
|
44
41
|
end
|
45
42
|
|
46
43
|
private
|
@@ -50,7 +47,7 @@ module AppStoreConnect
|
|
50
47
|
|
51
48
|
request = build_request(web_service_endpoint, **kwargs)
|
52
49
|
|
53
|
-
@
|
50
|
+
@usage.track
|
54
51
|
response = request.execute
|
55
52
|
|
56
53
|
JSON.parse(response.body) if response.body
|
@@ -63,31 +60,7 @@ module AppStoreConnect
|
|
63
60
|
end
|
64
61
|
|
65
62
|
def web_service_endpoint_by(alias_sym)
|
66
|
-
@
|
67
|
-
end
|
68
|
-
|
69
|
-
def env_options
|
70
|
-
{}.tap do |hash|
|
71
|
-
ENV.each do |key, value|
|
72
|
-
match = key.match(/APP_STORE_CONNECT_(?<name>[A-Z_]+)/)
|
73
|
-
|
74
|
-
next unless match
|
75
|
-
|
76
|
-
hash[match[:name].downcase.to_sym] = value
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def options(**kwargs)
|
82
|
-
defaults = {
|
83
|
-
analytics_enabled: true,
|
84
|
-
schema: Schema.new(File.join(__dir__, '../config/schema.json'))
|
85
|
-
}
|
86
|
-
AppStoreConnect.config.merge(kwargs.merge(env_options.merge(defaults))).tap do |options|
|
87
|
-
%i[key_id issuer_id private_key].each do |key|
|
88
|
-
raise ArgumentError, "missing #{key}" unless options.keys.include?(key)
|
89
|
-
end
|
90
|
-
end
|
63
|
+
@registry[alias_sym]
|
91
64
|
end
|
92
65
|
|
93
66
|
def http_body(web_service_endpoint, **kwargs)
|
@@ -3,15 +3,13 @@
|
|
3
3
|
require 'net/http'
|
4
4
|
|
5
5
|
module AppStoreConnect
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
class Request
|
7
|
+
class UnsupportedHTTPMethod < ArgumentError
|
8
|
+
def initialize(http_method)
|
9
|
+
super "Unsupported HTTP Method: #{http_method}"
|
10
|
+
end
|
11
11
|
end
|
12
|
-
end
|
13
12
|
|
14
|
-
class Request
|
15
13
|
def initialize(**options)
|
16
14
|
@uri = options.fetch(:uri)
|
17
15
|
@options = options
|
@@ -3,16 +3,13 @@
|
|
3
3
|
module AppStoreConnect
|
4
4
|
class Schema
|
5
5
|
class Type
|
6
|
-
attr_reader :type, :options
|
6
|
+
attr_reader :type, :options, :values
|
7
7
|
|
8
|
-
def initialize(
|
8
|
+
def initialize(options)
|
9
9
|
@type = options[:type]
|
10
|
+
@values = options[:values]
|
10
11
|
@options = options
|
11
12
|
end
|
12
|
-
|
13
|
-
def values
|
14
|
-
@options[:values]
|
15
|
-
end
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -1,19 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'app_store_connect/schema/type'
|
4
|
+
require 'app_store_connect/schema/object'
|
4
5
|
require 'app_store_connect/schema/web_service_endpoint'
|
5
6
|
|
6
7
|
module AppStoreConnect
|
7
8
|
class Schema
|
8
|
-
attr_reader :types, :web_service_endpoints
|
9
|
+
attr_reader :types, :web_service_endpoints, :objects
|
9
10
|
|
10
11
|
def initialize(path)
|
11
12
|
schema = JSON.parse(File.read(path)).deep_symbolize_keys
|
12
13
|
@types = schema[:types].map do |options|
|
13
|
-
Type.new(
|
14
|
+
Type.new(options)
|
14
15
|
end
|
15
|
-
@web_service_endpoints = schema[:web_service_endpoints].map do |
|
16
|
-
WebServiceEndpoint.new(
|
16
|
+
@web_service_endpoints = schema[:web_service_endpoints].map do |options|
|
17
|
+
WebServiceEndpoint.new(options)
|
18
|
+
end
|
19
|
+
@objects = schema[:objects].map do |options|
|
20
|
+
Object.new(options)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/app_store_connect.rb
CHANGED
@@ -14,7 +14,10 @@ require 'app_store_connect/user_invitation_create_request'
|
|
14
14
|
require 'app_store_connect/profile_create_request'
|
15
15
|
|
16
16
|
module AppStoreConnect
|
17
|
-
@config = {
|
17
|
+
@config = {
|
18
|
+
analytics_enabled: true,
|
19
|
+
schema: Schema.new(File.join(__dir__, 'config', 'schema.json'))
|
20
|
+
}
|
18
21
|
|
19
22
|
class << self
|
20
23
|
attr_accessor :config
|
data/lib/config/schema.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_store_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Decot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "<="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 5.2.3
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "<="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 5.2.3
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: jwt
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,20 +114,6 @@ dependencies:
|
|
120
114
|
- - "~>"
|
121
115
|
- !ruby/object:Gem::Version
|
122
116
|
version: '0.12'
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: rake
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - "~>"
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: '10.0'
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - "~>"
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: '10.0'
|
137
117
|
- !ruby/object:Gem::Dependency
|
138
118
|
name: rspec
|
139
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,15 +206,17 @@ files:
|
|
226
206
|
- Guardfile
|
227
207
|
- LICENSE.txt
|
228
208
|
- README.md
|
229
|
-
- Rakefile
|
230
209
|
- app_store_connect.gemspec
|
231
210
|
- bin/console
|
232
211
|
- bin/setup
|
233
212
|
- lib/app_store_connect.rb
|
234
|
-
- lib/app_store_connect/authorization.rb
|
235
213
|
- lib/app_store_connect/bundle_id_create_request.rb
|
236
214
|
- lib/app_store_connect/certificate_create_request.rb
|
237
215
|
- lib/app_store_connect/client.rb
|
216
|
+
- lib/app_store_connect/client/authorization.rb
|
217
|
+
- lib/app_store_connect/client/options.rb
|
218
|
+
- lib/app_store_connect/client/registry.rb
|
219
|
+
- lib/app_store_connect/client/usage.rb
|
238
220
|
- lib/app_store_connect/create_request.rb
|
239
221
|
- lib/app_store_connect/device_create_request.rb
|
240
222
|
- lib/app_store_connect/object/attributes.rb
|
@@ -244,6 +226,7 @@ files:
|
|
244
226
|
- lib/app_store_connect/profile_create_request.rb
|
245
227
|
- lib/app_store_connect/request.rb
|
246
228
|
- lib/app_store_connect/schema.rb
|
229
|
+
- lib/app_store_connect/schema/object.rb
|
247
230
|
- lib/app_store_connect/schema/type.rb
|
248
231
|
- lib/app_store_connect/schema/web_service_endpoint.rb
|
249
232
|
- lib/app_store_connect/user_invitation_create_request.rb
|
data/Rakefile
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'jwt'
|
4
|
-
|
5
|
-
module AppStoreConnect
|
6
|
-
class Authorization
|
7
|
-
AUDIENCE = 'appstoreconnect-v1'
|
8
|
-
ALGORITHM = 'ES256'
|
9
|
-
|
10
|
-
attr_reader :key_id, :issuer_id, :private_key
|
11
|
-
|
12
|
-
def initialize(key_id:, issuer_id:, private_key:)
|
13
|
-
@key_id = key_id
|
14
|
-
@issuer_id = issuer_id
|
15
|
-
@private_key = OpenSSL::PKey.read(private_key)
|
16
|
-
end
|
17
|
-
|
18
|
-
def payload
|
19
|
-
{
|
20
|
-
exp: Time.now.to_i + 20 * 60,
|
21
|
-
iss: issuer_id,
|
22
|
-
aud: AUDIENCE
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
def header_fields
|
27
|
-
{ kid: key_id }
|
28
|
-
end
|
29
|
-
|
30
|
-
def token
|
31
|
-
JWT.encode(payload, private_key, ALGORITHM, header_fields)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|