Class: ShopifyClient::Webhook

Inherits:
Struct
  • Object
show all
Defined in:
lib/shopify-client/webhook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#myshopify_domainString

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shopify-client/webhook.rb', line 12

Webhook = Struct.new(:myshopify_domain, :topic, :raw_data) do
  # @return [Hash]
  def data
    @data ||= JSON.parse(raw_data)
  rescue JSON::ParserError
    {}
  end

  alias_method :to_h, :data

  # @return [String]
  def to_json(*args)
    to_h.to_json(*args)
  end

  # @return [String]
  def inspect
    "#<ShopifyClient::Webhook (#{myshopify_domain}, #{topic})>"
  end
end

#raw_dataString

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shopify-client/webhook.rb', line 12

Webhook = Struct.new(:myshopify_domain, :topic, :raw_data) do
  # @return [Hash]
  def data
    @data ||= JSON.parse(raw_data)
  rescue JSON::ParserError
    {}
  end

  alias_method :to_h, :data

  # @return [String]
  def to_json(*args)
    to_h.to_json(*args)
  end

  # @return [String]
  def inspect
    "#<ShopifyClient::Webhook (#{myshopify_domain}, #{topic})>"
  end
end

#topicString

Returns:

  • (String)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shopify-client/webhook.rb', line 12

Webhook = Struct.new(:myshopify_domain, :topic, :raw_data) do
  # @return [Hash]
  def data
    @data ||= JSON.parse(raw_data)
  rescue JSON::ParserError
    {}
  end

  alias_method :to_h, :data

  # @return [String]
  def to_json(*args)
    to_h.to_json(*args)
  end

  # @return [String]
  def inspect
    "#<ShopifyClient::Webhook (#{myshopify_domain}, #{topic})>"
  end
end

Instance Method Details

#dataHash Also known as: to_h

Returns:

  • (Hash)


14
15
16
17
18
# File 'lib/shopify-client/webhook.rb', line 14

def data
  @data ||= JSON.parse(raw_data)
rescue JSON::ParserError
  {}
end

#inspectString

Returns:

  • (String)


28
29
30
# File 'lib/shopify-client/webhook.rb', line 28

def inspect
  "#<ShopifyClient::Webhook (#{myshopify_domain}, #{topic})>"
end

#to_json(*args) ⇒ String

Returns:

  • (String)


23
24
25
# File 'lib/shopify-client/webhook.rb', line 23

def to_json(*args)
  to_h.to_json(*args)
end