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.



8135
8136
8137
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8135

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

Instance Method Details

#delete_by_id(organization, id) ⇒ Object



8166
8167
8168
8169
8170
8171
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8166

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



8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8139

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



8159
8160
8161
8162
8163
8164
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8159

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



8152
8153
8154
8155
8156
8157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8152

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