Class: Io::Flow::V0::Clients::ShopifyPrivateApps

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ShopifyPrivateApps

Returns a new instance of ShopifyPrivateApps.



7297
7298
7299
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7297

def initialize(client)
  @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client)
end

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



7328
7329
7330
7331
7332
7333
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7328

def delete_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/shopify/private/apps/#{CGI.escape(id)}").delete
  nil
end

#get(organization, incoming = {}) ⇒ Object



7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7301

def get(organization, incoming={})
  HttpClient::Preconditions.assert_class('organization', organization, String)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  query = {
    :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }),
    :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer),
    :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer),
    :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String)
  }.delete_if { |k, v| v.nil? }
  r = @client.request("/#{CGI.escape(organization)}/shopify/private/apps").with_query(query).get
  r.map { |x| ::Io::Flow::V0::Models::ShopifyPrivateApp.new(x) }
end

#get_by_id(organization, id) ⇒ Object



7321
7322
7323
7324
7325
7326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7321

def get_by_id(organization, id)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  HttpClient::Preconditions.assert_class('id', id, String)
  r = @client.request("/#{CGI.escape(organization)}/shopify/private/apps/#{CGI.escape(id)}").get
  ::Io::Flow::V0::Models::ShopifyPrivateApp.new(r)
end

#put(organization, shopify_private_app_form) ⇒ Object



7314
7315
7316
7317
7318
7319
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 7314

def put(organization, shopify_private_app_form)
  HttpClient::Preconditions.assert_class('organization', organization, String)
  (x = shopify_private_app_form; x.is_a?(::Io::Flow::V0::Models::ShopifyPrivateAppForm) ? x : ::Io::Flow::V0::Models::ShopifyPrivateAppForm.new(x))
  r = @client.request("/#{CGI.escape(organization)}/shopify/private/apps").with_json(shopify_private_app_form.to_json).put
  ::Io::Flow::V0::Models::ShopifyPrivateApp.new(r)
end