class Lucid::Shopify::Client

Public Class Methods

new(bulk_request: Container[:bulk_request], send_request: Container[:send_request], send_throttled_request: Container[:send_throttled_request], throttling: true) click to toggle source

@param bulk_request [#call] @param send_request [#call] @param send_throttled_request [#call] @param throttling [Boolean]

# File lib/lucid/shopify/client.rb, line 14
def initialize(bulk_request: Container[:bulk_request],
               send_request: Container[:send_request],
               send_throttled_request: Container[:send_throttled_request],
               throttling: true)
  @bulk_request = bulk_request
  @send_request = send_request
  @send_throttled_request = send_throttled_request
  @throttling = throttling

  @params = {
    bulk_request: @bulk_request,
    send_request: @send_request,
    send_throttled_request: @send_throttled_request
  }
end

Public Instance Methods

authenticate(credentials) click to toggle source

@param credentials [Credentials]

@return [AuthenticatedClient]

# File lib/lucid/shopify/client.rb, line 61
def authenticate(credentials)
  AuthenticatedClient.new(self, credentials)
end
bulk(*args, &block) click to toggle source

If called with a block, calls {BulkRequest::Operation#call} immediately, else, returns the {BulkRequest::Operation}.

@see BulkRequest#call @see BulkRequest::Operation#call

# File lib/lucid/shopify/client.rb, line 70
def bulk(*args, &block)
  op = @bulk_request.(self, *args)

  block ? op.(&block) : op
end
delete(*args) click to toggle source

@see DeleteRequest#initialize

# File lib/lucid/shopify/client.rb, line 77
def delete(*args)
  send_request.(DeleteRequest.new(*args))
end
get(*args) click to toggle source

@see GetRequest#initialize

# File lib/lucid/shopify/client.rb, line 82
def get(*args)
  send_request.(GetRequest.new(*args))
end
post_graphql(*args) click to toggle source

@see GraphQLPostRequest#initialize

# File lib/lucid/shopify/client.rb, line 87
def post_graphql(*args)
  send_request.(GraphQLPostRequest.new(*args))
end
post_json(*args) click to toggle source

@see PostRequest#initialize

# File lib/lucid/shopify/client.rb, line 92
def post_json(*args)
  send_request.(PostRequest.new(*args))
end
put_json(*args) click to toggle source

@see PutRequest#initialize

# File lib/lucid/shopify/client.rb, line 97
def put_json(*args)
  send_request.(PutRequest.new(*args))
end
throttled() click to toggle source

Returns a new instance with throttling enabled, or self.

@return [Client, self]

# File lib/lucid/shopify/client.rb, line 43
def throttled
  return self if throttled?

  self.class.new(**@params, throttling: true)
end
throttled?() click to toggle source

@return [Boolean]

# File lib/lucid/shopify/client.rb, line 36
def throttled?
  @throttling
end
unthrottled() click to toggle source

Returns a new instance with throttling disabled, or self.

@return [Client, self]

# File lib/lucid/shopify/client.rb, line 52
def unthrottled
  return self unless throttled?

  self.class.new(**@params, throttling: false)
end

Private Instance Methods

send_request() click to toggle source

@return [#call]

# File lib/lucid/shopify/client.rb, line 31
        def send_request
  throttled? ? @send_throttled_request : @send_request
end