Sha256: 32f31e2294006e9bf27af6f34cc06bbc7d2690903939c1280bf358814e5f6ae6

Contents?: true

Size: 629 Bytes

Versions: 24

Compression:

Stored size: 629 Bytes

Contents

require 'rest-client'

class DiscoApp::ApiClient

  SUBSCRIPTION_ENDPOINT = 'app_subscriptions.json'

  def initialize(shop, url)
    @shop = shop
    @url = url
  end

  def create_app_subscription
    return unless @url.present?
    url = @url + SUBSCRIPTION_ENDPOINT
    begin
      response = 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.new(e.message)
    end
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/clients/disco_app/api_client.rb
disco_app-0.12.5 app/clients/disco_app/api_client.rb
disco_app-0.12.6 app/clients/disco_app/api_client.rb
disco_app-0.12.7 app/clients/disco_app/api_client.rb
disco_app-0.13.0 app/clients/disco_app/api_client.rb
disco_app-0.13.1 app/clients/disco_app/api_client.rb
disco_app-0.13.2 app/clients/disco_app/api_client.rb
disco_app-0.13.3 app/clients/disco_app/api_client.rb
disco_app-0.13.4 app/clients/disco_app/api_client.rb
disco_app-0.13.5 app/clients/disco_app/api_client.rb
disco_app-0.13.6 app/clients/disco_app/api_client.rb
disco_app-0.13.7 app/clients/disco_app/api_client.rb
disco_app-0.13.8 app/clients/disco_app/api_client.rb
disco_app-0.14.1 app/clients/disco_app/api_client.rb
disco_app-0.14.2 app/clients/disco_app/api_client.rb
disco_app-0.15.0 app/clients/disco_app/api_client.rb
disco_app-0.16.0 app/clients/disco_app/api_client.rb
disco_app-0.14.4 app/clients/disco_app/api_client.rb
disco_app-0.14.3 app/clients/disco_app/api_client.rb
disco_app-0.16.1 app/clients/disco_app/api_client.rb