app_store_connect_api_client 0.35.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +41 -0
  4. data/CHANGELOG.md +9 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +94 -0
  9. data/Rakefile +10 -0
  10. data/app_store_connect_api.gemspec +41 -0
  11. data/lib/app_store_connect_api/authorization.rb +36 -0
  12. data/lib/app_store_connect_api/client.rb +92 -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/utils/hash_utils.rb +22 -0
  50. data/lib/app_store_connect_api/utils/relationship_mapper.rb +47 -0
  51. data/lib/app_store_connect_api/utils/string_utils.rb +31 -0
  52. data/lib/app_store_connect_api/version.rb +5 -0
  53. data/lib/app_store_connect_api.rb +28 -0
  54. metadata +198 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a1c042aee9c9ab63edf5f8547ef4e3c2f49cfc813cf8c4b208dff368b86f2642
4
+ data.tar.gz: 976a6b19ebdc337e03ab17daddd33d45c78eb47482f3f1687997e9113567041e
5
+ SHA512:
6
+ metadata.gz: 8c5b60e4d7957304f12218521c3f2145243f6af2c5614703843d47f08401e671aeabdd150029578c29f91bc1c65b53abc2f209b47bc0184128481daef7c87753
7
+ data.tar.gz: 78ecee2f8011b316fe395bfeb25747061f7228b3b3b215041b242dfe25a7f95be0ba7020a08e1a03c4181f262f334af9dbd883a8aea390e3c8e9c2d8406b8c8a
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+ TargetRubyVersion: 2.7
7
+
8
+ Layout/LineLength:
9
+ Max: 180
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+ Style/StringConcatenation:
14
+ Enabled: false
15
+ Style/StringLiterals:
16
+ Enabled: false
17
+ Style/WordArray:
18
+ Enabled: false
19
+ Style/Not:
20
+ Enabled: false
21
+
22
+ Naming/RescuedExceptionsVariableName:
23
+ Enabled: false
24
+
25
+ Metrics/BlockLength:
26
+ Enabled: false
27
+
28
+ RSpec/AnyInstance:
29
+ Enabled: false
30
+ RSpec/ContextWording:
31
+ Enabled: false
32
+ RSpec/ExampleLength:
33
+ Enabled: false
34
+ RSpec/ImplicitSubject:
35
+ EnforcedStyle: single_statement_only
36
+ RSpec/MultipleExpectations:
37
+ Enabled: false
38
+ RSpec/MultipleMemoizedHelpers:
39
+ Enabled: false
40
+ RSpec/NestedGroups:
41
+ Max: 5
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.35.0] - 2023-06-05
8
+ ### Added
9
+ - Initial release.
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement via https://github.com/zormandi/app_store_connect_api.rb. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Zoltan Ormandi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # App Store Connect API client for Ruby
2
+
3
+ [![Build Status](https://github.com/zormandi/app_store_connect_api.rb/actions/workflows/main.yml/badge.svg)](https://github.com/zormandi/app_store_connect_api.rb/actions/workflows/main.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/app_store_connect_api_client.svg)](https://badge.fury.io/rb/app_store_connect_api_client)
5
+
6
+ This gem provides a thin Ruby wrapper around the [App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi) to make accessing App Store Connect more convenient and to help automate your Apple workflows.
7
+
8
+ It does not cover the complete domain of the App Store Connect API (yet), but
9
+ - it does cover the most commonly used APIs,
10
+ - it is robust and thoroughly tested,
11
+ - it's easy to understand and extend as it contains no metaprogramming (which also means you can have auto-completion with an IDE).
12
+
13
+ The list of supported domains can be found in the project's [domain folder](https://github.com/zormandi/app_store_connect_api.rb/blob/main/lib/app_store_connect_api/domain).
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'app_store_connect_api_client'
21
+ ```
22
+
23
+ and run:
24
+
25
+ ```bash
26
+ $ bundle install
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```ruby
32
+ client = AppStoreConnectApi::Client.new '<issuer ID>', '<key ID>', '<private key>'
33
+
34
+ # Simple query
35
+ client.apps filter: { bundle_id: 'company.org' }, limit: 5
36
+
37
+ # Including other resources
38
+ client.app_app_store_versions '1539394316',
39
+ filter: { platform: 'IOS', version_string: '2.2' },
40
+ include: 'appStoreVersionPhasedRelease,appStoreVersionLocalizations'
41
+
42
+ # Pagination
43
+ apps = client.apps limit: 10
44
+ while client.more? apps
45
+ apps = client.next apps
46
+ end
47
+
48
+ # Creating a resource
49
+ client.create_bundle_id identifier: 'id.bundle', name: 'Name', platform: 'IOS'
50
+
51
+ # Creating a resource with a relationship
52
+ app_store_version_attributes = {
53
+ version_string: '1.2',
54
+ platform: 'IOS',
55
+ # ...
56
+ }
57
+ client.create_app_store_version(app_store_version_attributes, app: '<app-id>') # Using the shorthand syntax for specifying relationships
58
+ client.create_app_store_version(app_store_version_attributes, app: { data: { id: '<app-id>', type: 'apps' } }) # Using the full relationship syntax
59
+
60
+ # Creating a resource with no attributes, just relationships
61
+ client.create_review_submission_item review_submission: '<review-submission-id>', app_store_version: '<app-store-version-id>'
62
+
63
+ # Updating attributes
64
+ client.update_app_store_version '<app-store-version-id>', version_string: '1.3'
65
+
66
+ # Updating attributes and relationships at the same time
67
+ client.update_app_store_version '<app-store-version-id>', { version_string: '1.3' }, build: '<build-id>'
68
+
69
+ # Deleting a resource
70
+ client.delete_app_store_version '<app-store-version-id>'
71
+
72
+ # Some endpoints expect an array of relationships
73
+ client.add_build_beta_groups '<build-id>', ['<beta-group-id1>', '<beta-group-id2>'] # Using the shorthand syntax for specifying relationships
74
+ client.add_build_beta_groups '<build-id>', [{ id: 'beta-group-id1', type: 'betaGroups' },
75
+ { id: 'beta-group-id2', type: 'betaGroups' }] # Using the full relationship syntax
76
+ ```
77
+
78
+ ## Development
79
+
80
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
81
+
82
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
83
+
84
+ ## Contributing
85
+
86
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zormandi/app_store_connect_api.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/zormandi/app_store_connect_api.rb/blob/main/CODE_OF_CONDUCT.md).
87
+
88
+ ## License
89
+
90
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
91
+
92
+ ## Code of Conduct
93
+
94
+ Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zormandi/app_store_connect_api.rb/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require 'rubocop/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
9
+
10
+ task default: :spec
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/app_store_connect_api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "app_store_connect_api_client"
7
+ spec.version = AppStoreConnectApi::VERSION
8
+ spec.authors = ["Zoltan Ormandi"]
9
+ spec.email = ["zoltan.ormandi@gmail.com"]
10
+
11
+ spec.summary = "A Ruby client for the App Store Connect API"
12
+ spec.description = "A thin Ruby wrapper around the App Store Connect API to provide a more convenient way of accessing App Store Connect."
13
+ spec.homepage = "https://github.com/zormandi/app_store_connect_api.rb"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/zormandi/app_store_connect_api.rb"
19
+ spec.metadata["changelog_uri"] = "https://github.com/zormandi/app_store_connect_api.rb/blob/main/CHANGELOG.md"
20
+ spec.metadata['rubygems_mfa_required'] = 'true'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_dependency "faraday"
34
+ spec.add_dependency "jwt", "~> 2.0"
35
+
36
+ spec.add_development_dependency "rake", "~> 13.0"
37
+ spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_development_dependency "rubocop", "~> 1.50"
39
+ spec.add_development_dependency "rubocop-rspec", "~> 2.22"
40
+ spec.add_development_dependency "webmock", "~> 3.0"
41
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ class Authorization
5
+ ALGORITHM = 'ES256'
6
+
7
+ def initialize(issuer_id, key_id, private_key)
8
+ @issuer_id = issuer_id
9
+ @key_id = key_id
10
+ @private_key = private_key
11
+ end
12
+
13
+ def token
14
+ JWT.encode payload, private_key, ALGORITHM, header_fields
15
+ end
16
+
17
+ private
18
+
19
+ def payload
20
+ {
21
+ iss: @issuer_id,
22
+ iat: Time.now.to_i,
23
+ exp: Time.now.to_i + (20 * 60),
24
+ aud: 'appstoreconnect-v1'
25
+ }
26
+ end
27
+
28
+ def private_key
29
+ OpenSSL::PKey.read @private_key
30
+ end
31
+
32
+ def header_fields
33
+ { kid: @key_id }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'authorization'
4
+ require_relative 'domain'
5
+ require_relative 'utils/hash_utils'
6
+ require_relative 'utils/relationship_mapper'
7
+ require_relative 'utils/string_utils'
8
+
9
+ module AppStoreConnectApi
10
+ class Client
11
+ include Domain
12
+
13
+ APP_STORE_CONNECT_API_ROOT_URL = 'https://api.appstoreconnect.apple.com'
14
+
15
+ def initialize(issuer_id, key_id, private_key)
16
+ @authorization = Authorization.new issuer_id, key_id, private_key
17
+ end
18
+
19
+ def get(path, options = {})
20
+ call_api :get, path, options
21
+ end
22
+
23
+ def post(path, body)
24
+ call_api :post, path, {}, body
25
+ end
26
+
27
+ def patch(path, body)
28
+ call_api :patch, path, {}, body
29
+ end
30
+
31
+ def delete(path, body = {})
32
+ call_api :delete, path, {}, body
33
+ end
34
+
35
+ def more?(resource)
36
+ not link_to_next_page_in(resource).nil?
37
+ end
38
+
39
+ def next(resource)
40
+ call_api :get, link_to_next_page_in(resource).sub(APP_STORE_CONNECT_API_ROOT_URL, '')
41
+ end
42
+
43
+ private
44
+
45
+ def link_to_next_page_in(response)
46
+ response.dig(:links, :next)
47
+ end
48
+
49
+ def call_api(method, path, params = {}, payload = {})
50
+ response = connection.send(method, path) do |req|
51
+ req.params = camel_case(params) unless params.empty?
52
+ req.body = camel_case(payload) unless payload.empty?
53
+ end
54
+ result = snake_case response.body
55
+ process_response response, result
56
+ rescue Faraday::Error => error
57
+ raise Error, error
58
+ end
59
+
60
+ def process_response(response, result)
61
+ if response.success?
62
+ result
63
+ elsif result.respond_to? :fetch
64
+ raise ApiError, result.fetch(:errors, [])
65
+ else
66
+ raise Error, result
67
+ end
68
+ end
69
+
70
+ def camel_case(params)
71
+ Utils::HashUtils.deep_transform_keys(params) { |key| Utils::StringUtils.camelize key.to_s }
72
+ end
73
+
74
+ def snake_case(response)
75
+ if response.is_a? Hash
76
+ Utils::HashUtils.deep_transform_keys(response) { |key| Utils::StringUtils.underscore(key).to_sym }
77
+ else
78
+ response
79
+ end
80
+ end
81
+
82
+ def connection
83
+ @connection ||= Faraday.new(url: APP_STORE_CONNECT_API_ROOT_URL,
84
+ request: { timeout: 3 },
85
+ headers: { 'Authorization' => "Bearer #{@authorization.token}" }) do |f|
86
+ f.request :json
87
+ f.response :json, content_type: /\bjson$/
88
+ f.adapter :net_http
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AgeRatingDeclarations
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/modify_an_age_rating_declaration
7
+ def update_age_rating_declaration(age_rating_declaration_id, attributes)
8
+ patch "/v1/ageRatingDeclarations/#{age_rating_declaration_id}", data: { attributes: attributes,
9
+ id: age_rating_declaration_id,
10
+ type: 'ageRatingDeclarations' }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AppAvailabilities
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_availability_for_an_app
7
+ def app_availability(app_availability_id, options = {})
8
+ get "/v1/appAvailabilities/#{app_availability_id}", options
9
+ end
10
+
11
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/modify_territory_availability_for_an_app
12
+ def create_app_availability(attributes, relationships)
13
+ post '/v1/appAvailabilities', data: { attributes: attributes,
14
+ relationships: Utils::RelationshipMapper.expand(relationships, 'availableTerritories' => 'territories'),
15
+ type: 'appAvailabilities' }
16
+ end
17
+
18
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/list_territory_availability_for_an_app
19
+ def app_availability_available_territories(app_availability_id, options = {})
20
+ get "/v1/appAvailabilities/#{app_availability_id}/availableTerritories", options
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AppCategories
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/list_app_categories
7
+ def app_categories(options = {})
8
+ get '/v1/appCategories', options
9
+ end
10
+
11
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_app_category_information
12
+ def app_category(app_category_id, options = {})
13
+ get "/v1/appCategories/#{app_category_id}", options
14
+ end
15
+
16
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/list_all_subcategories_for_an_app_category
17
+ def app_category_subcategories(app_category_id, options = {})
18
+ get "/v1/appCategories/#{app_category_id}/subcategories", options
19
+ end
20
+
21
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_parent_information_of_an_app_category
22
+ def app_category_parent(app_category_id, options = {})
23
+ get "/v1/appCategories/#{app_category_id}/parent", options
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AppInfoLocalizations
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_app_info_localization_information
7
+ def app_info_localization(app_info_localization_id, options = {})
8
+ get "/v1/appInfoLocalizations/#{app_info_localization_id}", options
9
+ end
10
+
11
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/create_an_app_info_localization
12
+ def create_app_info_localization(attributes, relationships)
13
+ post '/v1/appInfoLocalizations', data: { attributes: attributes,
14
+ relationships: Utils::RelationshipMapper.expand(relationships),
15
+ type: 'appInfoLocalizations' }
16
+ end
17
+
18
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/modify_an_app_info_localization
19
+ def update_app_info_localization(app_info_localization_id, attributes)
20
+ patch "/v1/appInfoLocalizations/#{app_info_localization_id}", data: { attributes: attributes,
21
+ id: app_info_localization_id,
22
+ type: 'appInfoLocalizations' }
23
+ end
24
+
25
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/delete_an_app_info_localization
26
+ def delete_app_info_localization(app_info_localization_id)
27
+ delete "/v1/appInfoLocalizations/#{app_info_localization_id}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AppInfos
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_app_info_information
7
+ def app_info(app_info_id, options = {})
8
+ get "/v1/appInfos/#{app_info_id}", options
9
+ end
10
+
11
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/modify_an_app_info
12
+ def update_app_info(app_info_id, relationships)
13
+ patch "/v1/appInfos/#{app_info_id}", data: { relationships: Utils::RelationshipMapper.expand(relationships, '*' => 'appCategories'),
14
+ id: app_info_id,
15
+ type: 'appInfos' }
16
+ end
17
+
18
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/list_all_app_info_localizations_for_an_app_info
19
+ def app_info_localizations(app_info_id, options = {})
20
+ get "/v1/appInfos/#{app_info_id}/appInfoLocalizations", options
21
+ end
22
+
23
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/get_v1_appinfos_id_ageratingdeclaration
24
+ def app_info_age_rating_declaration(app_info_id, options = {})
25
+ get "/v1/appInfos/#{app_info_id}/ageRatingDeclaration", options
26
+ end
27
+
28
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_secondary_category_information_of_an_app_info
29
+ def app_info_primary_category(app_info_id, options = {})
30
+ get "/v1/appInfos/#{app_info_id}/primaryCategory", options
31
+ end
32
+
33
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_primary_subcategory_one_information_of_an_app_info
34
+ def app_info_primary_subcategory_one(app_info_id, options = {})
35
+ get "/v1/appInfos/#{app_info_id}/primarySubcategoryOne", options
36
+ end
37
+
38
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_primary_subcategory_two_information_of_an_app_info
39
+ def app_info_primary_subcategory_two(app_info_id, options = {})
40
+ get "/v1/appInfos/#{app_info_id}/primarySubcategoryTwo", options
41
+ end
42
+
43
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_secondary_category_information_of_an_app_info
44
+ def app_info_secondary_category(app_info_id, options = {})
45
+ get "/v1/appInfos/#{app_info_id}/secondaryCategory", options
46
+ end
47
+
48
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_secondary_subcategory_one_information_of_an_app_info
49
+ def app_info_secondary_subcategory_one(app_info_id, options = {})
50
+ get "/v1/appInfos/#{app_info_id}/secondarySubcategoryOne", options
51
+ end
52
+
53
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_the_secondary_subcategory_two_information_of_an_app_info
54
+ def app_info_secondary_subcategory_two(app_info_id, options = {})
55
+ get "/v1/appInfos/#{app_info_id}/secondarySubcategoryTwo", options
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppStoreConnectApi
4
+ module Domain
5
+ module AppPricePoints
6
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/read_app_price_point_information-eg1
7
+ def app_price_point(app_price_point_id, options = {})
8
+ get "/v3/appPricePoints/#{app_price_point_id}", options
9
+ end
10
+
11
+ # @see https://developer.apple.com/documentation/appstoreconnectapi/list_app_price_point_equalizations
12
+ def app_price_point_equalizations(app_price_point_id, options = {})
13
+ get "/v3/appPricePoints/#{app_price_point_id}/equalizations", options
14
+ end
15
+ end
16
+ end
17
+ end