rocleung_as_api_client 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +41 -0
  4. data/CHANGELOG.md +6 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE +21 -0
  8. data/README.md +94 -0
  9. data/Rakefile +10 -0
  10. data/lib/app_store_connect_api/api_error.rb +31 -0
  11. data/lib/app_store_connect_api/authorization.rb +36 -0
  12. data/lib/app_store_connect_api/client.rb +84 -0
  13. data/lib/app_store_connect_api/domain/age_rating_declarations.rb +14 -0
  14. data/lib/app_store_connect_api/domain/app_availabilities.rb +24 -0
  15. data/lib/app_store_connect_api/domain/app_categories.rb +27 -0
  16. data/lib/app_store_connect_api/domain/app_info_localizations.rb +31 -0
  17. data/lib/app_store_connect_api/domain/app_infos.rb +59 -0
  18. data/lib/app_store_connect_api/domain/app_price_points.rb +17 -0
  19. data/lib/app_store_connect_api/domain/app_price_schedules.rb +35 -0
  20. data/lib/app_store_connect_api/domain/app_store_version_localizations.rb +31 -0
  21. data/lib/app_store_connect_api/domain/app_store_version_phased_releases.rb +26 -0
  22. data/lib/app_store_connect_api/domain/app_store_version_release_requests.rb +13 -0
  23. data/lib/app_store_connect_api/domain/app_store_versions.rb +77 -0
  24. data/lib/app_store_connect_api/domain/apps.rb +125 -0
  25. data/lib/app_store_connect_api/domain/beta_app_localizations.rb +41 -0
  26. data/lib/app_store_connect_api/domain/beta_app_review_details.rb +29 -0
  27. data/lib/app_store_connect_api/domain/beta_app_review_submissions.rb +28 -0
  28. data/lib/app_store_connect_api/domain/beta_build_localizations.rb +41 -0
  29. data/lib/app_store_connect_api/domain/beta_groups.rb +81 -0
  30. data/lib/app_store_connect_api/domain/beta_license_agreements.rb +29 -0
  31. data/lib/app_store_connect_api/domain/beta_tester_invitations.rb +14 -0
  32. data/lib/app_store_connect_api/domain/beta_testers.rb +84 -0
  33. data/lib/app_store_connect_api/domain/build_beta_details.rb +29 -0
  34. data/lib/app_store_connect_api/domain/build_beta_notifications.rb +13 -0
  35. data/lib/app_store_connect_api/domain/builds.rb +105 -0
  36. data/lib/app_store_connect_api/domain/bundle_id_capabilities.rb +28 -0
  37. data/lib/app_store_connect_api/domain/bundle_ids.rb +50 -0
  38. data/lib/app_store_connect_api/domain/certificates.rb +29 -0
  39. data/lib/app_store_connect_api/domain/customer_reviews.rb +12 -0
  40. data/lib/app_store_connect_api/domain/devices.rb +31 -0
  41. data/lib/app_store_connect_api/domain/prerelease_versions.rb +27 -0
  42. data/lib/app_store_connect_api/domain/profiles.rb +44 -0
  43. data/lib/app_store_connect_api/domain/review_submission_items.rb +25 -0
  44. data/lib/app_store_connect_api/domain/review_submissions.rb +36 -0
  45. data/lib/app_store_connect_api/domain/sandbox_testers.rb +25 -0
  46. data/lib/app_store_connect_api/domain/user_invitations.rb +36 -0
  47. data/lib/app_store_connect_api/domain/users.rb +55 -0
  48. data/lib/app_store_connect_api/domain.rb +77 -0
  49. data/lib/app_store_connect_api/response.rb +87 -0
  50. data/lib/app_store_connect_api/utils/hash_utils.rb +22 -0
  51. data/lib/app_store_connect_api/utils/relationship_mapper.rb +47 -0
  52. data/lib/app_store_connect_api/utils/string_utils.rb +31 -0
  53. data/lib/app_store_connect_api/version.rb +5 -0
  54. data/lib/app_store_connect_api.rb +12 -0
  55. data/renovate.json +6 -0
  56. metadata +210 -0
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_error'
4
+
5
+ module AppStoreConnectApi
6
+ class Response
7
+ def initialize(raw_response, relationships = '')
8
+ relationships = '' if relationships.nil?
9
+ relationships = relationships.split(",")
10
+
11
+ @raw_response = snake_case(raw_response)
12
+ @relationships = snake_case(relationships)
13
+ end
14
+
15
+ def response
16
+ return if @raw_response.empty?
17
+ raise Error, @raw_response unless @raw_response.is_a? Hash
18
+
19
+ if @raw_response.key? :errors
20
+ raise ApiError, @raw_response[:errors]
21
+ elsif @raw_response.key? :data
22
+ process_data_from_response
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def snake_case(data)
29
+ if data.is_a? Hash
30
+ Utils::HashUtils.deep_transform_keys(data) { |key| Utils::StringUtils.underscore(key).to_sym }
31
+ elsif data.is_a? Array
32
+ data.map do |item|
33
+ if item.is_a? Hash
34
+ Utils::HashUtils.deep_transform_keys(data) { |key| Utils::StringUtils.underscore(key).to_sym }
35
+ else
36
+ Utils::StringUtils.underscore(item).to_sym
37
+ end
38
+ end
39
+ else
40
+ data
41
+ end
42
+ end
43
+
44
+ def process_data_from_response
45
+ case @raw_response[:data]
46
+ when Array
47
+ @raw_response[:data].map { |item| process_data_item item, @relationships }
48
+ else
49
+ process_data_item @raw_response[:data], @relationships
50
+ end
51
+ end
52
+
53
+ def process_data_item(item, relationships = [])
54
+ return item unless item.is_a? Hash
55
+
56
+ result = { id: item[:id] }
57
+ result.merge! item[:attributes] unless item[:attributes].nil?
58
+ relationships.each do |relationship|
59
+ result = process_relationship item, relationship, result
60
+ end
61
+
62
+ result
63
+ end
64
+
65
+ def process_relationship(item, relationship, data_item)
66
+ related_item = item[:relationships][relationship]
67
+ data_item[:"#{relationship}_total"] = related_item[:meta][:paging][:total] if related_item.dig :meta, :paging
68
+ data_item[relationship] = process_relationship_data related_item[:data]
69
+ data_item
70
+ end
71
+
72
+ def process_relationship_data(relationship_data)
73
+ return relationship_data if relationship_data.nil? || relationship_data.empty?
74
+
75
+ return relationship_data.map { |relationship_id| related_included_item_for relationship_id } if relationship_data.is_a? Array
76
+
77
+ related_included_item_for relationship_data
78
+ end
79
+
80
+ def related_included_item_for(relationship_id)
81
+ return relationship_id unless relationship_id.is_a?(Hash)
82
+
83
+ related_item = @raw_response[:included].find { |el| el[:type] == relationship_id[:type] && el[:id] == relationship_id[:id] }
84
+ process_data_item related_item
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Utils
5
+ module HashUtils
6
+ class << self
7
+ def deep_transform_keys(object, &block)
8
+ case object
9
+ when Hash
10
+ object.each_with_object({}) do |(key, value), result|
11
+ result[yield(key)] = deep_transform_keys value, &block
12
+ end
13
+ when Array
14
+ object.map { |item| deep_transform_keys item, &block }
15
+ else
16
+ object
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Utils
5
+ module RelationshipMapper
6
+ class << self
7
+ def expand(relationships, type_translations = {})
8
+ relationships.each_with_object({}) do |(relationship_type, resource_id), result|
9
+ result[relationship_type] = { data: expand_relationship(resource_id, relationship_type, type_translations) }
10
+ end
11
+ end
12
+
13
+ def resource_keys(ids, resource_type, type_translations = {})
14
+ ids.map { |id| resource_key id, resource_type, type_translations }
15
+ end
16
+
17
+ private
18
+
19
+ def expand_relationship(resource_id, relationship_type, type_translations)
20
+ return resource_id[:data] if full_format_resource_identifier? resource_id
21
+
22
+ if resource_id.is_a? Array
23
+ resource_keys resource_id, to_resource_type(relationship_type, already_plural: true), type_translations
24
+ else
25
+ resource_key resource_id, to_resource_type(relationship_type, already_plural: false), type_translations
26
+ end
27
+ end
28
+
29
+ def full_format_resource_identifier?(resource_id)
30
+ resource_id.is_a?(Hash) && resource_id.key?(:data)
31
+ end
32
+
33
+ def resource_key(id, resource_type, type_translations = {})
34
+ return id unless id.is_a? String
35
+
36
+ { id: id, type: type_translations[resource_type] || type_translations['*'] || resource_type }
37
+ end
38
+
39
+ def to_resource_type(relationship_type, already_plural:)
40
+ result = relationship_type.to_s
41
+ result = StringUtils.pluralize(result) unless already_plural
42
+ StringUtils.camelize result
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Utils
5
+ module StringUtils
6
+ class << self
7
+ def camelize(snake_cased_word)
8
+ snake_cased_word.split('_')
9
+ .map(&:capitalize)
10
+ .join
11
+ .tap { |w| w[0] = w[0].downcase }
12
+ end
13
+
14
+ def underscore(camel_cased_word)
15
+ camel_cased_word.gsub(/([a-z])([A-Z])/, '\1_\2')
16
+ .downcase
17
+ end
18
+
19
+ def pluralize(word)
20
+ if word.end_with? 's'
21
+ word + 'es'
22
+ elsif word.end_with? 'y'
23
+ word[...-1] + 'ies'
24
+ else
25
+ word + 's'
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ VERSION = "0.38.0"
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'openssl'
4
+ require 'jwt'
5
+ require 'faraday'
6
+ require 'faraday/retry'
7
+ require_relative "app_store_connect_api/client"
8
+ require_relative "app_store_connect_api/version"
9
+
10
+ module AppStoreConnectApi
11
+ class Error < StandardError; end
12
+ end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "local>bitrise-io/renovate-config:web-pillar-repositories"
5
+ ]
6
+ }
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rocleung_as_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.38.0
5
+ platform: ruby
6
+ authors:
7
+ - rocleung
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-retry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jwt
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A thin Ruby wrapper around the App Store Connect API to provide a more
126
+ convenient way of accessing App Store Connect.
127
+ email:
128
+ - rocleung@live.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - CHANGELOG.md
136
+ - CODE_OF_CONDUCT.md
137
+ - Gemfile
138
+ - LICENSE
139
+ - README.md
140
+ - Rakefile
141
+ - lib/app_store_connect_api.rb
142
+ - lib/app_store_connect_api/api_error.rb
143
+ - lib/app_store_connect_api/authorization.rb
144
+ - lib/app_store_connect_api/client.rb
145
+ - lib/app_store_connect_api/domain.rb
146
+ - lib/app_store_connect_api/domain/age_rating_declarations.rb
147
+ - lib/app_store_connect_api/domain/app_availabilities.rb
148
+ - lib/app_store_connect_api/domain/app_categories.rb
149
+ - lib/app_store_connect_api/domain/app_info_localizations.rb
150
+ - lib/app_store_connect_api/domain/app_infos.rb
151
+ - lib/app_store_connect_api/domain/app_price_points.rb
152
+ - lib/app_store_connect_api/domain/app_price_schedules.rb
153
+ - lib/app_store_connect_api/domain/app_store_version_localizations.rb
154
+ - lib/app_store_connect_api/domain/app_store_version_phased_releases.rb
155
+ - lib/app_store_connect_api/domain/app_store_version_release_requests.rb
156
+ - lib/app_store_connect_api/domain/app_store_versions.rb
157
+ - lib/app_store_connect_api/domain/apps.rb
158
+ - lib/app_store_connect_api/domain/beta_app_localizations.rb
159
+ - lib/app_store_connect_api/domain/beta_app_review_details.rb
160
+ - lib/app_store_connect_api/domain/beta_app_review_submissions.rb
161
+ - lib/app_store_connect_api/domain/beta_build_localizations.rb
162
+ - lib/app_store_connect_api/domain/beta_groups.rb
163
+ - lib/app_store_connect_api/domain/beta_license_agreements.rb
164
+ - lib/app_store_connect_api/domain/beta_tester_invitations.rb
165
+ - lib/app_store_connect_api/domain/beta_testers.rb
166
+ - lib/app_store_connect_api/domain/build_beta_details.rb
167
+ - lib/app_store_connect_api/domain/build_beta_notifications.rb
168
+ - lib/app_store_connect_api/domain/builds.rb
169
+ - lib/app_store_connect_api/domain/bundle_id_capabilities.rb
170
+ - lib/app_store_connect_api/domain/bundle_ids.rb
171
+ - lib/app_store_connect_api/domain/certificates.rb
172
+ - lib/app_store_connect_api/domain/customer_reviews.rb
173
+ - lib/app_store_connect_api/domain/devices.rb
174
+ - lib/app_store_connect_api/domain/prerelease_versions.rb
175
+ - lib/app_store_connect_api/domain/profiles.rb
176
+ - lib/app_store_connect_api/domain/review_submission_items.rb
177
+ - lib/app_store_connect_api/domain/review_submissions.rb
178
+ - lib/app_store_connect_api/domain/sandbox_testers.rb
179
+ - lib/app_store_connect_api/domain/user_invitations.rb
180
+ - lib/app_store_connect_api/domain/users.rb
181
+ - lib/app_store_connect_api/response.rb
182
+ - lib/app_store_connect_api/utils/hash_utils.rb
183
+ - lib/app_store_connect_api/utils/relationship_mapper.rb
184
+ - lib/app_store_connect_api/utils/string_utils.rb
185
+ - lib/app_store_connect_api/version.rb
186
+ - renovate.json
187
+ homepage:
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: 2.6.9
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ requirements: []
206
+ rubygems_version: 3.0.3.1
207
+ signing_key:
208
+ specification_version: 4
209
+ summary: A Ruby client for the App Store Connect API
210
+ test_files: []