Skip to content

Commit

Permalink
Manage in app purchases (#131)
Browse files Browse the repository at this point in the history
* Add console script

Co-authored-by: Tomislav Markanovic <[email protected]>

* List all price points for an app

Co-authored-by: Tomislav Markanovic <[email protected]>

* Listing inAppPurchases and their details

Co-authored-by: Tomislav Markanovic <[email protected]>

* Manage In-App Purchases

Co-authored-by: Tomislav Markanovic <[email protected]>

* List In-App Purchase localizations

Co-authored-by: Tomislav Markanovic <[email protected]>

---------

Co-authored-by: Tomislav Markanovic <[email protected]>
  • Loading branch information
gregg-platogo and tmarkanov authored Feb 7, 2023
1 parent d46e8a8 commit 026f830
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 5 deletions.
15 changes: 15 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'app_store_connect'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require 'irb'
IRB.start(__FILE__)
2 changes: 2 additions & 0 deletions lib/app_store_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
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/requests/v2/in_app_purchase/create'
require 'app_store_connect/requests/v2/in_app_purchase/update'
require 'app_store_connect/profile_create_request'
require 'app_store_connect/beta_build_localization_create_request'
require 'app_store_connect/beta_build_localization_modify_request'
Expand Down
26 changes: 26 additions & 0 deletions lib/app_store_connect/requests/v2/in_app_purchase/create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
module Requests
module V2
module InAppPurchase
class Create < CreateRequest
data do
type 'inAppPurchases'

attributes do
property :name, required: true
property :product_id, required: true
property :in_app_purchase_type, required: true
property :available_in_all_territories
property :family_sharable
property :review_note
end
end
end
end
end
end
end
25 changes: 25 additions & 0 deletions lib/app_store_connect/requests/v2/in_app_purchase/update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require 'app_store_connect/create_request'

module AppStoreConnect
module Requests
module V2
module InAppPurchase
class Update < CreateRequest
data do
id
type 'inAppPurchases'

attributes do
property :name
property :available_in_all_territories
property :family_sharable
property :review_note
end
end
end
end
end
end
end
56 changes: 53 additions & 3 deletions lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,48 @@
"url": "https://api.appstoreconnect.apple.com/v1/apps/{id}",
"alias": "app"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v1/apps/{id}/pricePoints",
"alias": "app_price_points"
},
{
"alias": "create_in_app_purchase",
"http_body_type": "Requests::V2::InAppPurchase::Create",
"http_method": "post",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases"
},
{
"alias": "update_in_app_purchase",
"http_body_type": "Requests::V2::InAppPurchase::Update",
"http_method": "patch",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases/{id}"
},
{
"alias": "delete_in_app_purchase",
"http_method": "delete",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases/{id}"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases/{id}",
"alias": "in_app_purchase"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v1/apps/{id}/inAppPurchasesV2",
"alias": "app_in_app_purchases"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases/{id}/pricePoints",
"alias": "in_app_purchase_price_points"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v2/inAppPurchases/{id}/inAppPurchaseLocalizations",
"alias": "in_app_purchase_localizations"
},
{
"http_method": "get",
"url": "https://api.appstoreconnect.apple.com/v1/apps/{id}/betaGroups",
Expand Down Expand Up @@ -792,6 +834,13 @@
}
],
"types": [
{
"type": "BundleIdPlatform",
"values": [
"IOS",
"MAC_OS"
]
},
{
"type": "CapabilityType",
"values": [
Expand Down Expand Up @@ -833,10 +882,11 @@
]
},
{
"type": "BundleIdPlatform",
"type": "InAppPurchaseType",
"values": [
"IOS",
"MAC_OS"
"CONSUMABLE",
"NON_CONSUMABLE",
"NON_RENEWING_SUBSCRIPTION"
]
},
{
Expand Down
32 changes: 32 additions & 0 deletions spec/app_store_connect/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,38 @@
it_behaves_like :get_request, path: 'apps/1234'
end

describe '#app_price_points' do
let(:id) { '1234' }

before { subject.app_price_points(id: id) }

it_behaves_like :get_request, path: 'apps/1234/pricePoints'
end

describe '#in_app_purchase' do
let(:id) { '1234' }

before { subject.in_app_purchase(id: id) }

it_behaves_like :get_request, api_version: 'v2', path: 'inAppPurchases/1234'
end

describe '#app_in_app_purchases' do
let(:id) { '1234' }

before { subject.app_in_app_purchases(id: id) }

it_behaves_like :get_request, path: 'apps/1234/inAppPurchasesV2'
end

describe '#in_app_purchase_price_points' do
let(:id) { '1234' }

before { subject.in_app_purchase_price_points(id: id) }

it_behaves_like :get_request, api_version: 'v2', path: 'inAppPurchases/1234/pricePoints'
end

describe '#builds' do
let(:id) { '1234' }

Expand Down
4 changes: 2 additions & 2 deletions spec/support/shared_examples/get_request.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

RSpec.shared_examples :get_request do |path:, query_parameters: nil|
RSpec.shared_examples :get_request do |path:, api_version: 'v1', query_parameters: nil|
it do
uri = "https://api.appstoreconnect.apple.com/v1/#{path}"
uri = "https://api.appstoreconnect.apple.com/#{api_version}/#{path}"

uri += "?#{query_parameters.to_query}" if query_parameters

Expand Down

0 comments on commit 026f830

Please sign in to comment.