Class: ShopifyAPI::GraphQL::Bulk::Operation::Result
- Inherits:
-
Object
- Object
- ShopifyAPI::GraphQL::Bulk::Operation::Result
- Defined in:
- lib/shopify_api/graphql/bulk/operation/result.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#user_errors ⇒ Object
readonly
Returns the value of attribute user_errors.
Instance Method Summary collapse
-
#initialize(row) ⇒ Result
constructor
A new instance of Result.
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
#data ⇒ Object (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 |
#errors ⇒ Object (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 |
#line ⇒ Object (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_errors ⇒ Object (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 |