tiny_appstore_connect 0.1.4 → 0.1.5
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/lib/tiny_appstore_connect/client.rb +2 -1
- data/lib/tiny_appstore_connect/clients/certificate.rb +5 -1
- data/lib/tiny_appstore_connect/clients/device.rb +4 -0
- data/lib/tiny_appstore_connect/models/certificate.rb +34 -12
- data/lib/tiny_appstore_connect/response.rb +33 -43
- data/lib/tiny_appstore_connect/version.rb +1 -1
- data/lib/tiny_appstore_connect.rb +23 -12
- data/tiny_appstore_connect.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62e9ae341686817d57e8f0ea7833eef6be53a5a7c1e6416ffd4e81916375a61c
|
4
|
+
data.tar.gz: a9ad021b50df72944688a01c3c2670ace550a669de1efd9677df51af04459117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d9fcb1dad512e6650168ef085d0ff3b546d2f7c3e23d383349899606c935537aa49f9b7bcc4191fab213c4aadf11988b3e132b40568a39cb0148c99f38b63a8
|
7
|
+
data.tar.gz: c01a733a86ad47db48eaacf20c96cacb7019c60c4b6adf660385583719b26608f1a303eebd119cc131c33b6cca968f21b702802609808f7fdffb5985d254f04b
|
@@ -59,8 +59,9 @@ module TinyAppstoreConnect
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def handle_response(response)
|
62
|
-
response = Response.new(response,
|
62
|
+
response = Response.new(response, self)
|
63
63
|
|
64
|
+
# It always never to be go into here, throws a 429 error.
|
64
65
|
if (remaining = response.rate[:remaining]) && remaining.to_i.zero?
|
65
66
|
raise RateLimitExceededError, "Request limit reached #{response.rate[:limit]}
|
66
67
|
in the previous 60 minutes with url: #{response.request_url}"
|
@@ -15,7 +15,11 @@ class TinyAppstoreConnect::Client
|
|
15
15
|
|
16
16
|
def distribution_certificates(**query)
|
17
17
|
query[:filter] = {
|
18
|
-
certificateType:
|
18
|
+
certificateType: [
|
19
|
+
TinyAppstoreConnect::Model::Certificate::CertificateType::DISTRIBUTION,
|
20
|
+
TinyAppstoreConnect::Model::Certificate::CertificateType::IOS_DISTRIBUTION,
|
21
|
+
TinyAppstoreConnect::Model::Certificate::CertificateType::MAC_APP_DISTRIBUTION
|
22
|
+
].join(',')
|
19
23
|
}
|
20
24
|
|
21
25
|
certificates(**query)
|
@@ -31,22 +31,44 @@ module TinyAppstoreConnect::Model
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def team_id
|
34
|
-
|
35
|
-
.to_a
|
36
|
-
.find {|n, _, _| n == 'OU'}[1]
|
37
|
-
.force_encoding('UTF-8')
|
34
|
+
subject['OU']
|
38
35
|
end
|
39
36
|
|
40
|
-
def
|
41
|
-
|
37
|
+
def name
|
38
|
+
subject['O']
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_name
|
42
|
+
subject['CN']
|
43
|
+
end
|
44
|
+
# def type
|
45
|
+
# value = subject['CN']
|
46
|
+
# if value.include?('Distribution')
|
47
|
+
# return 'Distribution'
|
48
|
+
# else
|
49
|
+
# return ''
|
50
|
+
# end
|
51
|
+
# end
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
def subject
|
54
|
+
@subject ||= certificate.subject
|
55
|
+
.to_a
|
56
|
+
.each_with_object({}) do |(key, value, _), obj|
|
57
|
+
obj[key] = value.force_encoding('UTF-8')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def certificate
|
62
|
+
@certificate ||= -> () do
|
63
|
+
require 'openssl'
|
64
|
+
data = [
|
65
|
+
'-----BEGIN CERTIFICATE-----',
|
66
|
+
certificate_content,
|
67
|
+
'-----END CERTIFICATE-----'
|
68
|
+
].join("\n")
|
48
69
|
|
49
|
-
|
70
|
+
OpenSSL::X509::Certificate.new(data)
|
71
|
+
end.call
|
50
72
|
end
|
51
73
|
|
52
74
|
def self.type
|
@@ -10,14 +10,14 @@ module TinyAppstoreConnect
|
|
10
10
|
# include Enumerable
|
11
11
|
extend Forwardable
|
12
12
|
|
13
|
-
attr_reader :response, :
|
13
|
+
attr_reader :response, :client
|
14
14
|
|
15
|
-
def initialize(response,
|
15
|
+
def initialize(response, client)
|
16
16
|
@response = response
|
17
|
-
@
|
17
|
+
@client = client
|
18
18
|
end
|
19
19
|
|
20
|
-
def_delegators :@response, :status, :headers
|
20
|
+
def_delegators :@response, :status, :headers, :body
|
21
21
|
|
22
22
|
def request_url
|
23
23
|
@response.env.url
|
@@ -37,57 +37,47 @@ module TinyAppstoreConnect
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
return if
|
40
|
+
def next_url
|
41
|
+
return if body.nil?
|
42
42
|
|
43
|
-
links =
|
44
|
-
links[
|
43
|
+
links = body['links'] || {}
|
44
|
+
links['next']
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
def next_page(&block)
|
48
|
+
url = next_url
|
49
|
+
return if url.nil?
|
50
|
+
return client.get(url) unless block_given?
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
# count = 0 if count <= 0
|
54
|
-
|
55
|
-
# responses = [self]
|
56
|
-
# counter = 0
|
57
|
-
|
58
|
-
# resp = self
|
59
|
-
# loop do
|
60
|
-
# resp = resp.next_page
|
61
|
-
# break if resp.nil?
|
62
|
-
|
63
|
-
# responses << resp
|
64
|
-
# counter += 1
|
65
|
-
|
66
|
-
# break if counter >= count
|
67
|
-
# end
|
52
|
+
yield(url)
|
53
|
+
end
|
68
54
|
|
69
|
-
|
70
|
-
|
55
|
+
def next_pages(count: 1, &block)
|
56
|
+
count = 0 if !count.nil? && count < 0
|
57
|
+
responses = [self]
|
58
|
+
counter = 0
|
71
59
|
|
72
|
-
|
73
|
-
|
60
|
+
resp = self
|
61
|
+
loop do
|
62
|
+
resp = resp.next_page(&block)
|
63
|
+
break if resp.nil?
|
74
64
|
|
75
|
-
|
76
|
-
|
77
|
-
# end
|
65
|
+
responses << resp
|
66
|
+
counter += 1
|
78
67
|
|
79
|
-
|
80
|
-
|
68
|
+
break if !count.nil? && counter >= count
|
69
|
+
end
|
81
70
|
|
82
|
-
|
83
|
-
|
71
|
+
responses
|
72
|
+
end
|
84
73
|
|
85
|
-
def
|
86
|
-
|
74
|
+
def all_pages(flatten: false, &block)
|
75
|
+
responses = next_pages(count: nil, &block)
|
76
|
+
flatten ? responses.flat_map(&:to_models) : responses
|
87
77
|
end
|
88
78
|
|
89
79
|
def to_models
|
90
|
-
return [] if
|
80
|
+
return [] if body.nil?
|
91
81
|
|
92
82
|
model_or_models = Parser.parse(response, rate)
|
93
83
|
[model_or_models].flatten
|
@@ -95,7 +85,7 @@ module TinyAppstoreConnect
|
|
95
85
|
|
96
86
|
def each(&block)
|
97
87
|
to_models.each do |model|
|
98
|
-
|
88
|
+
yield(model)
|
99
89
|
end
|
100
90
|
end
|
101
91
|
end
|
@@ -10,38 +10,49 @@ module TinyAppstoreConnect
|
|
10
10
|
class Error < StandardError; end
|
11
11
|
|
12
12
|
class ConnectAPIError < Error
|
13
|
+
attr_reader :status_code, :errors
|
14
|
+
|
13
15
|
class << self
|
14
16
|
def parse(response)
|
15
|
-
handel_error(response
|
17
|
+
handel_error(response)
|
16
18
|
end
|
17
19
|
|
18
|
-
def from_errors(
|
20
|
+
def from_errors(response)
|
21
|
+
status_code = response.status
|
22
|
+
# 403 will returns content-type with value '*/*' FUCK!
|
23
|
+
body = response.body.is_a?(String) ? JSON.load(response.body) : response.body
|
24
|
+
errors = body['errors']
|
19
25
|
message = ["Check errors(#{errors.size}) from response:"]
|
20
26
|
errors.each_with_index do |error, i|
|
21
27
|
message << "#{i + 1} - [#{error['status']}] #{error['title']}: #{error['detail']} in #{error['source']}"
|
22
28
|
end
|
23
29
|
|
24
|
-
new(message)
|
30
|
+
new(message, status_code, errors)
|
25
31
|
end
|
26
32
|
|
27
33
|
private
|
28
34
|
|
29
|
-
def handel_error(
|
30
|
-
case
|
35
|
+
def handel_error(response)
|
36
|
+
case response.status
|
31
37
|
# Unauthorized
|
32
|
-
when 401 then InvalidUserCredentialsError.from_errors(
|
33
|
-
# The API key in use does not allow this request
|
34
|
-
when 403 then ForbiddenError.from_errors(
|
38
|
+
when 401 then InvalidUserCredentialsError.from_errors(response)
|
39
|
+
# The API key in use does not allow this request (API role problems)
|
40
|
+
when 403 then ForbiddenError.from_errors(response)
|
35
41
|
# Not found resource
|
36
|
-
when 404 then NotFoundError.from_errors(
|
42
|
+
when 404 then NotFoundError.from_errors(response)
|
37
43
|
# Invaild request entity
|
38
|
-
when 409 then InvalidEntityError.from_errors(
|
44
|
+
when 409 then InvalidEntityError.from_errors(response)
|
39
45
|
# 429 Rate Limit Exceeded
|
40
|
-
when 429 then RateLimitExceededError.from_errors(
|
41
|
-
else ConnectAPIError.from_errors(
|
46
|
+
when 429 then RateLimitExceededError.from_errors(response)
|
47
|
+
else ConnectAPIError.from_errors(response)
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
51
|
+
|
52
|
+
def initialize(message, status_code, errors)
|
53
|
+
@status_code, @errors = status_code, errors
|
54
|
+
super(message)
|
55
|
+
end
|
45
56
|
end
|
46
57
|
|
47
58
|
class RateLimitExceededError < ConnectAPIError; end
|
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
29
|
spec.add_dependency 'faraday', '>= 1.10.0', '< 3.0'
|
30
|
-
spec.add_dependency 'jwt', '>= 1.4', '
|
31
|
-
spec.add_dependency 'openssl', '>=
|
30
|
+
spec.add_dependency 'jwt', '>= 1.4', '< 3'
|
31
|
+
spec.add_dependency 'openssl', '>= 2.2.1', '< 4'
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_appstore_connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icyleaf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -37,9 +37,9 @@ dependencies:
|
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.4'
|
40
|
-
- - "
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: '3'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,16 +47,16 @@ dependencies:
|
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.4'
|
50
|
-
- - "
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: '3'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: openssl
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 2.2.1
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '4'
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 2.2.1
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '4'
|