Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new endpoints #118

Merged
merged 9 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/app_store_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

require 'app_store_connect/client'
require 'app_store_connect/object/type'
require 'app_store_connect/object/id'
require 'app_store_connect/object/attributes'
require 'app_store_connect/object/properties'
require 'app_store_connect/object/data'
require 'app_store_connect/version'

require 'app_store_connect/bundle_id_create_request'
require 'app_store_connect/app_store_version_build_linkage_request'
require 'app_store_connect/app_store_version_create_request'
require 'app_store_connect/app_store_version_update_request'
require 'app_store_connect/bundle_id_capability_create_request'
require 'app_store_connect/bundle_id_create_request'
require 'app_store_connect/certificate_create_request'
require 'app_store_connect/device_create_request'
require 'app_store_connect/user_invitation_create_request'
require 'app_store_connect/profile_create_request'
require 'app_store_connect/review_submission_create_request'
require 'app_store_connect/review_submission_item_create_request'
require 'app_store_connect/review_submission_update_request'
require 'app_store_connect/user_invitation_create_request'

module AppStoreConnect
@config = {}
Expand Down
12 changes: 12 additions & 0 deletions lib/app_store_connect/app_store_version_build_linkage_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class AppStoreVersionBuildLinkageRequest < CreateRequest
data do
id :build_id
type 'builds'
end
end
end
19 changes: 19 additions & 0 deletions lib/app_store_connect/app_store_version_create_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class AppStoreVersionCreateRequest < CreateRequest
data do
type 'appStoreVersions'

attributes do
property :copyright
property :earliest_release_date
property :platform, required: true
property :release_type
property :version_string, required: true
end
end
end
end
20 changes: 20 additions & 0 deletions lib/app_store_connect/app_store_version_update_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class AppStoreVersionUpdateRequest < CreateRequest
data do
id
type 'appStoreVersions'

attributes do
property :copyright
property :earliest_release_date
property :release_type
property :version_string
property :downloadable
end
end
end
end
4 changes: 2 additions & 2 deletions lib/app_store_connect/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def web_service_endpoint_aliases
private

def call(web_service_endpoint, **kwargs)
raise "invalid http method: #{web_service_endpoint.http_method}" unless %i[get delete post].include?(web_service_endpoint.http_method)
raise "invalid http method: #{web_service_endpoint.http_method}" unless %i[get delete post patch].include?(web_service_endpoint.http_method)

request = build_request(web_service_endpoint, **kwargs)

Expand Down Expand Up @@ -80,7 +80,7 @@ def build_request(web_service_endpoint, **kwargs)
headers: headers
}

options[:http_body] = http_body(web_service_endpoint, **kwargs) if web_service_endpoint.http_method == :post
options[:http_body] = http_body(web_service_endpoint, **kwargs) if %i[post patch].include?(web_service_endpoint.http_method)

Request.new(**options)
end
Expand Down
6 changes: 5 additions & 1 deletion lib/app_store_connect/object/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ module Data
klass = Class.new do |data|
include Object::Attributes
include Object::Type
include Object::Id

data.send(:define_method, :initialize) do |**kwargs|
instance_variable_set('@relationships', kwargs.delete(:relationships).to_h)
instance_variable_set('@attributes', data::Attributes.new(**kwargs))
instance_variable_set('@id', kwargs[id_arg_name])
end

def to_h
{
props = {
relationships: @relationships,
attributes: attributes.to_h,
type: type
}
props[:id] = @id if id?
props.compact_blank
end
end

Expand Down
28 changes: 28 additions & 0 deletions lib/app_store_connect/object/id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require 'active_support/concern'

module AppStoreConnect
module Object
module Id
extend ActiveSupport::Concern

class_methods do
def id(arg_name = :id)
@include_id_in_body = true
@id_arg_name = arg_name
end
end

included do
def id?
self.class.instance_variable_get('@include_id_in_body')
end

def id_arg_name
self.class.instance_variable_get('@id_arg_name')
end
end
end
end
end
15 changes: 15 additions & 0 deletions lib/app_store_connect/review_submission_create_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class ReviewSubmissionCreateRequest < CreateRequest
data do
type 'reviewSubmissions'

attributes do
property :platform, required: true
end
end
end
end
11 changes: 11 additions & 0 deletions lib/app_store_connect/review_submission_item_create_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class ReviewSubmissionItemCreateRequest < CreateRequest
data do
type 'reviewSubmissionItems'
end
end
end
17 changes: 17 additions & 0 deletions lib/app_store_connect/review_submission_update_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
class ReviewSubmissionUpdateRequest < CreateRequest
data do
id
type 'reviewSubmissions'

attributes do
property :canceled
property :submitted
end
end
end
end
Loading