app_store_connect 0.7.0 → 0.8.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/.gitignore +1 -0
- data/Gemfile.lock +0 -8
- data/README.md +2 -2
- data/app_store_connect.gemspec +0 -1
- data/lib/app_store_connect.rb +0 -1
- data/lib/app_store_connect/client.rb +37 -45
- data/lib/app_store_connect/create_request.rb +4 -2
- data/lib/app_store_connect/object/type.rb +0 -2
- data/lib/app_store_connect/request.rb +86 -0
- data/lib/app_store_connect/user_invitation_create_request.rb +13 -16
- data/lib/app_store_connect/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 828bfc36ad01d4b563b45842227d5a6bdb8174e5861ff697d7cf44fe208dbd0a
|
|
4
|
+
data.tar.gz: a46feefa242d7cbd7a250864b02c279cb5ccbabd8f3ec455fb4a9432f85d879c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b4e5e5be24f9b2a82bc64c75ece2b2e5f5aaa41042320216b72bf692226cbe542d4d24485220c5f9de2b05bf0b310a700f2ba8e6bf2ea51c4c13ce0229c74cf
|
|
7
|
+
data.tar.gz: bbb0c90614528a5efd338f27ac418995673f084fe6bb1892e48849d1eed836a670d4e8b85aad1c699cb33f8ccbc94969be974c61d860de41dc2a3fab8843d271
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -3,7 +3,6 @@ PATH
|
|
|
3
3
|
specs:
|
|
4
4
|
app_store_connect (0.7.0)
|
|
5
5
|
activesupport (~> 5.2.3)
|
|
6
|
-
httparty (~> 0.16)
|
|
7
6
|
jwt (~> 2.1)
|
|
8
7
|
|
|
9
8
|
GEM
|
|
@@ -42,9 +41,6 @@ GEM
|
|
|
42
41
|
guard-compat (~> 1.1)
|
|
43
42
|
rspec (>= 2.99.0, < 4.0)
|
|
44
43
|
hashdiff (0.4.0)
|
|
45
|
-
httparty (0.17.0)
|
|
46
|
-
mime-types (~> 3.0)
|
|
47
|
-
multi_xml (>= 0.5.2)
|
|
48
44
|
i18n (1.6.0)
|
|
49
45
|
concurrent-ruby (~> 1.0)
|
|
50
46
|
jaro_winkler (1.5.3)
|
|
@@ -56,11 +52,7 @@ GEM
|
|
|
56
52
|
ruby_dep (~> 1.2)
|
|
57
53
|
lumberjack (1.0.13)
|
|
58
54
|
method_source (0.9.2)
|
|
59
|
-
mime-types (3.2.2)
|
|
60
|
-
mime-types-data (~> 3.2015)
|
|
61
|
-
mime-types-data (3.2019.0331)
|
|
62
55
|
minitest (5.11.3)
|
|
63
|
-
multi_xml (0.6.0)
|
|
64
56
|
nenv (0.3.0)
|
|
65
57
|
notiffany (0.1.1)
|
|
66
58
|
nenv (~> 0.1)
|
data/README.md
CHANGED
|
@@ -32,8 +32,8 @@ AppStoreConnect.config = {
|
|
|
32
32
|
app_store_connect = AppStoreConnect::Client.new
|
|
33
33
|
|
|
34
34
|
app_store_connect.apps
|
|
35
|
-
app_store_connect.app('1234')
|
|
36
|
-
app_store_connect.builds('1234')
|
|
35
|
+
app_store_connect.app(id: '1234')
|
|
36
|
+
app_store_connect.builds(id: '1234')
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
## Development
|
data/app_store_connect.gemspec
CHANGED
|
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.require_paths = ['lib']
|
|
22
22
|
|
|
23
23
|
spec.add_runtime_dependency 'activesupport', '~> 5.2.3'
|
|
24
|
-
spec.add_runtime_dependency 'httparty', '~> 0.16'
|
|
25
24
|
spec.add_runtime_dependency 'jwt', '~> 2.1'
|
|
26
25
|
|
|
27
26
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
data/lib/app_store_connect.rb
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
require 'active_support/all'
|
|
4
4
|
|
|
5
5
|
require 'app_store_connect/web_service_endpoint'
|
|
6
|
+
require 'app_store_connect/request'
|
|
6
7
|
|
|
7
8
|
module AppStoreConnect
|
|
8
|
-
class Client
|
|
9
|
+
class Client
|
|
9
10
|
def initialize(**kwargs)
|
|
10
11
|
@options = options(**kwargs)
|
|
11
12
|
|
|
@@ -40,27 +41,24 @@ module AppStoreConnect
|
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def call(web_service_endpoint, **kwargs)
|
|
44
|
+
parser = proc do |response|
|
|
45
|
+
JSON.parse(response.body)
|
|
46
|
+
end
|
|
47
|
+
|
|
43
48
|
case web_service_endpoint.http_method
|
|
44
49
|
when :get
|
|
45
|
-
get(web_service_endpoint, **kwargs)
|
|
50
|
+
get(web_service_endpoint, **kwargs, &parser)
|
|
46
51
|
when :post
|
|
47
|
-
post(web_service_endpoint, **kwargs)
|
|
52
|
+
post(web_service_endpoint, **kwargs, &parser)
|
|
48
53
|
else
|
|
49
54
|
raise "invalid http method: #{web_service_endpoint.http_method}"
|
|
50
55
|
end
|
|
51
56
|
end
|
|
52
57
|
|
|
53
|
-
def
|
|
54
|
-
web_service_endpoint
|
|
55
|
-
.url
|
|
56
|
-
.gsub(/(\{(\w+)\})/) { kwargs.fetch(Regexp.last_match(2).to_sym) }
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def url_parameter_names(web_service_endpoint)
|
|
60
|
-
web_service_endpoint
|
|
58
|
+
def build_uri(web_service_endpoint, **kwargs)
|
|
59
|
+
URI(web_service_endpoint
|
|
61
60
|
.url
|
|
62
|
-
.
|
|
63
|
-
.map { |_, n| n.to_sym }
|
|
61
|
+
.gsub(/(\{(\w+)\})/) { kwargs.fetch(Regexp.last_match(2).to_sym) })
|
|
64
62
|
end
|
|
65
63
|
|
|
66
64
|
def web_service_endpoint_by(name:)
|
|
@@ -87,44 +85,38 @@ module AppStoreConnect
|
|
|
87
85
|
end
|
|
88
86
|
end
|
|
89
87
|
|
|
90
|
-
def
|
|
91
|
-
request
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
query_parameters = kwargs.dup.tap do |hash|
|
|
99
|
-
url_parameter_names(web_service_endpoint).each do |name|
|
|
100
|
-
hash.delete(name.to_sym)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
88
|
+
def get(web_service_endpoint, **kwargs, &block)
|
|
89
|
+
request = Request.new(
|
|
90
|
+
kwargs: kwargs,
|
|
91
|
+
web_service_endpoint: web_service_endpoint,
|
|
92
|
+
http_method: :get,
|
|
93
|
+
uri: build_uri(web_service_endpoint, **kwargs),
|
|
94
|
+
headers: headers
|
|
95
|
+
)
|
|
103
96
|
|
|
104
|
-
|
|
97
|
+
request.execute(&block)
|
|
105
98
|
end
|
|
106
99
|
|
|
107
|
-
def
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
def http_body(web_service_endpoint, **kwargs)
|
|
101
|
+
"AppStoreConnect::#{web_service_endpoint.http_body_type}"
|
|
102
|
+
.constantize
|
|
103
|
+
.new(**kwargs)
|
|
104
|
+
.to_h
|
|
105
|
+
.deep_transform_keys { |k| k.to_s.camelize(:lower) }
|
|
106
|
+
.to_json
|
|
114
107
|
end
|
|
115
108
|
|
|
116
|
-
def post(web_service_endpoint, **kwargs)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
109
|
+
def post(web_service_endpoint, **kwargs, &block)
|
|
110
|
+
request = Request.new(
|
|
111
|
+
web_service_endpoint: web_service_endpoint,
|
|
112
|
+
kwargs: kwargs,
|
|
113
|
+
http_method: :post,
|
|
114
|
+
uri: build_uri(web_service_endpoint, **kwargs),
|
|
115
|
+
headers: headers,
|
|
116
|
+
http_body: http_body(web_service_endpoint, **kwargs)
|
|
117
|
+
)
|
|
125
118
|
|
|
126
|
-
|
|
127
|
-
HTTParty.send(http_method, url, options)
|
|
119
|
+
request.execute(&block)
|
|
128
120
|
end
|
|
129
121
|
|
|
130
122
|
def headers
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module AppStoreConnect
|
|
4
4
|
class CreateRequest
|
|
5
|
-
|
|
5
|
+
def self.inherited(klass)
|
|
6
|
+
klass.include(Object::Data)
|
|
7
|
+
end
|
|
6
8
|
|
|
7
9
|
def initialize(**kwargs)
|
|
8
|
-
@data = Data.new(kwargs)
|
|
10
|
+
@data = self.class::Data.new(kwargs)
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'net/http'
|
|
4
|
+
|
|
5
|
+
module AppStoreConnect
|
|
6
|
+
attr_reader :uri
|
|
7
|
+
|
|
8
|
+
class Request
|
|
9
|
+
def initialize(**options)
|
|
10
|
+
@uri = options.fetch(:uri)
|
|
11
|
+
@options = options
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def execute
|
|
15
|
+
Net::HTTP.start(uri.host, uri.port, net_http_options) do |http|
|
|
16
|
+
response = http.request(request)
|
|
17
|
+
|
|
18
|
+
yield response if block_given?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def web_service_endpoint
|
|
25
|
+
@options.fetch(:web_service_endpoint)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def query
|
|
29
|
+
return unless http_method == :get
|
|
30
|
+
|
|
31
|
+
kwargs.dup.tap do |hash|
|
|
32
|
+
url_parameter_names(web_service_endpoint).each do |name|
|
|
33
|
+
hash.delete(name.to_sym)
|
|
34
|
+
end
|
|
35
|
+
end.to_query
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def http_method
|
|
39
|
+
@options.fetch(:http_method).to_sym
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def net_http_options
|
|
43
|
+
{ use_ssl: uri.scheme == 'https' }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def kwargs
|
|
47
|
+
@options.fetch(:kwargs, {})
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def uri
|
|
51
|
+
@options.fetch(:uri).tap do |uri|
|
|
52
|
+
uri.query = query if http_method == :get
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def headers
|
|
57
|
+
@options.fetch(:headers, {})
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def body
|
|
61
|
+
return if http_method == :get
|
|
62
|
+
|
|
63
|
+
@options.fetch(:http_body)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def url_parameter_names(web_service_endpoint)
|
|
67
|
+
web_service_endpoint
|
|
68
|
+
.url
|
|
69
|
+
.scan(/(\{(\w+)\})/)
|
|
70
|
+
.map { |_, n| n.to_sym }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def request
|
|
74
|
+
case http_method
|
|
75
|
+
when :get
|
|
76
|
+
Net::HTTP::Get.new(uri, headers)
|
|
77
|
+
when :post
|
|
78
|
+
Net::HTTP::Post.new(uri, headers).tap do |request|
|
|
79
|
+
request.body = body
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
raise "unsupported http method: #{http_method}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class UserInvitationCreateRequest < Struct.new(:first_name, :last_name, :email, :roles)
|
|
5
|
-
def initialize(kwargs)
|
|
6
|
-
super(kwargs[:first_name], kwargs[:last_name], kwargs[:email], kwargs[:roles])
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def body
|
|
10
|
-
{ 'data' =>
|
|
11
|
-
{ 'type' => 'userInvitations', 'attributes' =>
|
|
12
|
-
{ 'firstName' => first_name, 'lastName' => last_name, 'email' => email, 'roles' => roles, 'allAppsVisible' => true, 'provisioningAllowed' => true } } }
|
|
13
|
-
end
|
|
3
|
+
require 'app_store_connect/create_request'
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
module AppStoreConnect
|
|
6
|
+
class UserInvitationCreateRequest < CreateRequest
|
|
7
|
+
data do
|
|
8
|
+
type 'userInvitations'
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
attributes do
|
|
11
|
+
property :first_name, required: true
|
|
12
|
+
property :last_name, required: true
|
|
13
|
+
property :email, required: true
|
|
14
|
+
property :roles, required: true
|
|
15
|
+
property :all_apps_visible
|
|
16
|
+
property :provisioning_allowed
|
|
17
|
+
end
|
|
21
18
|
end
|
|
22
19
|
end
|
|
23
20
|
end
|
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.8.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-08-
|
|
11
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -24,20 +24,6 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 5.2.3
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: httparty
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.16'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.16'
|
|
41
27
|
- !ruby/object:Gem::Dependency
|
|
42
28
|
name: jwt
|
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -229,6 +215,7 @@ files:
|
|
|
229
215
|
- lib/app_store_connect/object/properties.rb
|
|
230
216
|
- lib/app_store_connect/object/type.rb
|
|
231
217
|
- lib/app_store_connect/parser.rb
|
|
218
|
+
- lib/app_store_connect/request.rb
|
|
232
219
|
- lib/app_store_connect/type.rb
|
|
233
220
|
- lib/app_store_connect/type/enum.rb
|
|
234
221
|
- lib/app_store_connect/user_invitation_create_request.rb
|