Class: ShopifyAPI::GraphQL::Bulk::Operation::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_api/graphql/bulk/operation/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row) ⇒ Result

Returns a new instance of Result.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shopify_api/graphql/bulk/operation/result.rb', line 10

def initialize(row)
  @errors = []
  @user_errors = []

  @line = row["__lineNumber"]

  if row.include?("errors")
    @errors = row["errors"].map { |e| { :message => e["message"] } }
  end

  if row["data"]
    data = row["data"].values.first
    if data
      errors = data["userErrors"] || []
      @user_errors = errors.map { |e| { :field => e["field"], :message => e["message"] } } if errors.any?
      @data = snake_case_keys(data.reject { |k, _| k == "userErrors" })
    end
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/shopify_api/graphql/bulk/operation/result.rb', line 8

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/shopify_api/graphql/bulk/operation/result.rb', line 8

def errors
  @errors
end

#lineObject (readonly)

Returns the value of attribute line.



8
9
10
# File 'lib/shopify_api/graphql/bulk/operation/result.rb', line 8

def line
  @line
end

#user_errorsObject (readonly)

Returns the value of attribute user_errors.



8
9
10
# File 'lib/shopify_api/graphql/bulk/operation/result.rb', line 8

def user_errors
  @user_errors
end