Class: AppStoreServerApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/app_store_server_api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(private_key:, key_id:, issuer_id:, bundle_id:, environment: :production) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/app_store_server_api/client.rb', line 10

def initialize(
  private_key:, # p8 key
  key_id:,      # Your private key ID from App Store Connect (Ex: 2X9R4HXF34)
  issuer_id:,   # Your issuer ID from the Keys page in App Store Connect
  bundle_id:,   # Your app’s bundle ID (Ex: “com.example.testbundleid”)
  environment: :production
)

  @private_key = private_key
  @key_id = key_id
  @issuer_id = issuer_id
  @bundle_id = bundle_id
  @base_url = app_store_base_url environment.to_sym
end

Instance Method Details

#get_all_subscription_statuses(transaction_id, params: nil) ⇒ Object

status

1, The auto-renewable subscription is active. 2, The auto-renewable subscription is expired. 3, The auto-renewable subscription is in a billing retry period. 4, The auto-renewable subscription is in a Billing Grace Period. 5, The auto-renewable subscription is revoked. The App Store refunded the transaction or revoked it from Family Sharing



40
41
42
# File 'lib/app_store_server_api/client.rb', line 40

def get_all_subscription_statuses(transaction_id, params: nil)
  request_uri("#{@base_url}/inApps/v1/subscriptions/#{transaction_id}", params: params)
end

#get_transaction_history(transaction_id, params: nil) ⇒ Object



25
26
27
# File 'lib/app_store_server_api/client.rb', line 25

def get_transaction_history(transaction_id, params: nil)
  request_uri("#{@base_url}/inApps/v1/history/#{transaction_id}", params: params)
end

#get_transaction_info(transaction_id, params: nil) ⇒ Object



29
30
31
# File 'lib/app_store_server_api/client.rb', line 29

def get_transaction_info(transaction_id, params: nil)
  request_uri("#{@base_url}/inApps/v1/transactions/#{transaction_id}", params: params)
end

#request_a_test_notificationObject



44
45
46
# File 'lib/app_store_server_api/client.rb', line 44

def request_a_test_notification
  request_uri "#{@base_url}/inApps/v1/notifications/test", http_method: :post
end