/
marketplace.rb
56 lines (52 loc) · 2.04 KB
/
marketplace.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
module Octokit
class Client
# Methods for the Marketplace Listing API
#
# @see https://developer.github.com/v3/apps/marketplace/
module Marketplace
# List all plans for an app's marketplace listing
#
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/marketplace/#list-all-plans-for-your-marketplace-listing
#
# @return [Array<Sawyer::Resource>] A list of plans
def list_plans(options = {})
paginate '/marketplace_listing/plans', options
end
# List all GitHub accounts on a specific plan
#
# @param plan_id [Integer] The id of the GitHub plan
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan
#
# @return [Array<Sawyer::Resource>] A list of accounts
def list_accounts_for_plan(plan_id, options = {})
paginate "/marketplace_listing/plans/#{plan_id}/accounts", options
end
# Get the plan associated with a given GitHub account
#
# @param account_id [Integer] The id of the GitHub account
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing
#
# @return <Sawyer::Resource> Account with plan details, or nil
def plan_for_account(account_id, options = {})
get "/marketplace_listing/accounts/#{account_id}", options
end
# Get user's Marketplace purchases
#
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/marketplace/#get-a-users-marketplace-purchases
#
# @return [Array<Sawyer::Resource>] A list of Marketplace purchases
def marketplace_purchases(options = {})
get '/user/marketplace_purchases', options
end
end
end
end