Class: Lucid::Shopify::Client

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Client.

Parameters:

  • bulk_request (#call) (defaults to: Container[:bulk_request])
  • send_request (#call) (defaults to: Container[:send_request])
  • send_throttled_request (#call) (defaults to: Container[:send_throttled_request])
  • throttling (Boolean) (defaults to: true)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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

Instance Method Details

#authenticate(credentials) ⇒ AuthenticatedClient

Parameters:

Returns:



61
62
63
# File 'lib/lucid/shopify/client.rb', line 61

def authenticate(credentials)
  AuthenticatedClient.new(self, credentials)
end

#bulk(*args, &block) ⇒ Object

See Also:



66
67
68
# File 'lib/lucid/shopify/client.rb', line 66

def bulk(*args, &block)
  @bulk_request.(self, *args, &block)
end

#delete(*args) ⇒ Object



71
72
73
# File 'lib/lucid/shopify/client.rb', line 71

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

#get(*args) ⇒ Object



76
77
78
# File 'lib/lucid/shopify/client.rb', line 76

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

#post_graphql(*args) ⇒ Object



81
82
83
# File 'lib/lucid/shopify/client.rb', line 81

def post_graphql(*args)
  send_request.(PostGraphQLRequest.new(*args))
end

#post_json(*args) ⇒ Object



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

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

#put_json(*args) ⇒ Object



91
92
93
# File 'lib/lucid/shopify/client.rb', line 91

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

#throttledClient, self

Returns a new instance with throttling enabled, or self.

Returns:



43
44
45
46
47
# File 'lib/lucid/shopify/client.rb', line 43

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:



52
53
54
55
56
# File 'lib/lucid/shopify/client.rb', line 52

def unthrottled
  return self unless throttled?

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