Sha256: 85fa56919c005f79dbd88475f6205bfb91baf654f858171b3bc117578cdc0312
Contents?: true
Size: 713 Bytes
Versions: 6
Compression:
Stored size: 713 Bytes
Contents
require 'rest-client' module DiscoApp class DiscoApiError < StandardError; end class ApiClient SUBSCRIPTION_ENDPOINT = 'app_subscriptions.json'.freeze def initialize(shop, url) @shop = shop @url = url end def create_app_subscription return if @url.blank? url = @url + SUBSCRIPTION_ENDPOINT begin RestClient::Request.execute( method: :post, headers: { content_type: :json }, url: url, payload: { shop: @shop, subscription: @shop.current_subscription }.to_json ) rescue RestClient::BadRequest, RestClient::ResourceNotFound => e raise DiscoApiError, e.message end end end end
Version data entries
6 entries across 6 versions & 1 rubygems