Class: LucidShopify::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid_shopify/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(send_request: Container[:send_request], send_throttled_request: Container[:send_throttled_request], throttling: false) ⇒ Client

Returns a new instance of Client.

Parameters:

  • send_request (#call) (defaults to: Container[:send_request])
  • send_throttled_request (#call) (defaults to: Container[:send_throttled_request])


13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lucid_shopify/client.rb', line 13

def initialize(send_request: Container[:send_request],
               send_throttled_request: Container[:send_throttled_request],
               throttling: false)
  @send_request = send_request
  @send_throttled_request = send_throttled_request
  @throttling = throttling

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

Instance Method Details

#delete(*args) ⇒ Object



65
66
67
# File 'lib/lucid_shopify/client.rb', line 65

def delete(*args)
  send_request.(DeleteRequest.new(*args))
end

#get(*args) ⇒ Object



72
73
74
# File 'lib/lucid_shopify/client.rb', line 72

def get(*args)
  send_request.(GetRequest.new(*args))
end

#post_json(*args) ⇒ Object



79
80
81
# File 'lib/lucid_shopify/client.rb', line 79

def post_json(*args)
  send_request.(PostRequest.new(*args))
end

#put_json(*args) ⇒ Object



86
87
88
# File 'lib/lucid_shopify/client.rb', line 86

def put_json(*args)
  send_request.(PutRequest.new(*args))
end

#throttledClient, self

Returns a new instance with throttling enabled, or self.

Returns:



45
46
47
48
49
# File 'lib/lucid_shopify/client.rb', line 45

def throttled
  return self if throttled?

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

#throttled?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/lucid_shopify/client.rb', line 36

def throttled?
  @throttling
end

#unthrottledClient, self

Returns a new instance with throttling disabled, or self.

Returns:



56
57
58
59
60
# File 'lib/lucid_shopify/client.rb', line 56

def unthrottled
  return self unless throttled?

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