Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

Fixes DiscountCode errors type, adds new BatchResult type #1276

Closed sle-c closed 9 months ago

sle-c commented 9 months ago

Description

Follow up on https://github.com/Shopify/shopify-api-ruby/pull/1205

How has this been tested?

Setup a new ruby project with the following script

# main.rb
require 'shopify_api'

access_token = '<truncated>'
shop = '<truncated>'

test_session = ShopifyAPI::Auth::Session.new(
  shop:,
  access_token:
)

ShopifyAPI::Context.setup(
  api_key: '<truncated>',
  api_secret_key: '<truncated>',
  api_version: '2024-01',
  scope: 'read_products, price_rules',
  is_private: false,
  is_embedded: true
)

ShopifyAPI::Context.activate_session(test_session)

response = ShopifyAPI::DiscountCode.get_batch_results(
  session: test_session,
  price_rule_id: 1445781537073,
  batch_id: 416335102257,
)
p response

Run it with

bundle exec ruby main.rb

This script prints the following result

[
  <ShopifyAPI::DiscountCode::BatchResult code="SUMMERSALE10OFF1" errors={"code"=>["must be unique. Please try a different code."]} id=nil>, 
  <ShopifyAPI::DiscountCode::BatchResult code="SUMMER2" errors={"code"=>["must be unique. Please try a different code."]} id=nil>, 
  <ShopifyAPI::DiscountCode::BatchResult code="SUMMER3" errors={"code"=>["must be unique. Please try a different code."]} id=nil>
]

Checklist:

sle-c commented 9 months ago

closed because we decided that this issue is not worth fixing given that the documentation and generated will be diverged by this solution