class Bio::BaseSpace::BillingAPI
The API class used for all communication with the BaseSpace
Billng server.
Public Class Methods
new(api_server, version, app_session_id = nil, access_token = nil)
click to toggle source
Create a new BillingAPI
object.
api_server
-
URI of the
BaseSpace
API server. version
-
Version of the API to use.
app_session_id
-
AppSession
ID. access_token
-
Access token that is provided by App triggering.
Calls superclass method
Bio::BaseSpace::BaseAPI::new
# File lib/basespace/api/billing_api.rb, line 29 def initialize(api_server, version, app_session_id = nil, access_token = nil) end_with_slash = %r(/$) unless api_server[end_with_slash] api_server += '/' end @app_session_id = app_session_id @api_server = api_server + version @version = version super(access_token) end
Public Instance Methods
create_purchase(products, app_session_id = nil)
click to toggle source
Creates a purchase with the specified products.
products
-
List of dicts to purchase, each of which has a product ‘id’ and ‘quantity’ to purchase.
app_session_id
-
AppSession
ID.
# File lib/basespace/api/billing_api.rb, line 46 def create_purchase(products, app_session_id = nil) my_model = 'PurchaseResponse' resource_path = '/purchases/' resource_path = resource_path.sub('{format}', 'json') method = 'POST' query_params = {} header_params = {} post_data = {} # 'Products' is list of dicts with 'id', 'quantity', and optnl 'tags[]' post_data['Products'] = products if app_session_id post_data['AppSessionId'] = app_session_id end verbose = false return single_request(my_model, resource_path, method, query_params, header_params, post_data, verbose) end
get_purchase_by_id(id)
click to toggle source
Request a purchase object by ID.
id
-
The ID of the purchase.
# File lib/basespace/api/billing_api.rb, line 66 def get_purchase_by_id(id) my_model = 'PurchaseResponse' resource_path = '/purchases/{Id}' resource_path = resource_path.sub('{format}', 'json') resource_path = resource_path.sub('{Id}', id) method = 'GET' query_params = {} header_params = {} return single_request(my_model, resource_path, method, query_params, header_params) end
get_user_products(id = 'current', qps = {})
click to toggle source
Returns the Products for the current user.
id
-
The ID of the user.
qps
-
Query parameters, a dictionary for filtering by ‘Tags’ and/or ‘ProductIds’.
# File lib/basespace/api/billing_api.rb, line 81 def get_user_products(id = 'current', qps = {}) query_pars = QueryParametersPurchasedProduct.new(qps) my_model = 'PurchasedProduct' resource_path = '/users/{Id}/products' resource_path = resource_path.sub('{Id}', id.to_s) method = 'GET' query_params = query_pars.get_parameter_dict header_params = {} return self.__listRequest__(my_model, resource_path, method, query_params, header_params) end
refund_purchase(purchase_id, refund_secret, comment = nil)
click to toggle source
Creates a purchase with the specified products.
purchase_id
-
The ID of the purchase.
refund_secret
-
The RefundSecret that was provided in the Response from createPurchase.
comment
-
An optional comment about the refund.
# File lib/basespace/api/billing_api.rb, line 97 def refund_purchase(purchase_id, refund_secret, comment = nil) my_model = 'RefundPurchaseResponse' resource_path = '/purchases/{id}/refund' resource_path = resource_path.sub('{id}', purchase_id) method = 'POST' query_params = {} header_params = {} post_data = {} post_data['RefundSecret'] = refund_secret if comment post_data['Comment'] = comment end verbose = 0 return single_request(my_model, resource_path, method, query_params, header_params, post_data, verbose) end