shopify_api_bruv 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 071160b2ae93014ee98671f497785156a97fb15784e1b667af8fcfb8c0578531
4
- data.tar.gz: 82b819215557f3c9f4f9a15adffe1cd3e5981f393ab03a80c8556fe8ced971b7
3
+ metadata.gz: 352d24353de02f75eacf6c36787cb7874b39ca1a46861fda5e7158b3c832849c
4
+ data.tar.gz: af2a5e82844ee8ab33f6084594ffb36f9849ba00204fb75f33478fc7a5fbaa02
5
5
  SHA512:
6
- metadata.gz: 8709e9ca0f3636aabbab6b6a8eefa94a0f50948021a09d287270d2e455f66563cb834bf24e26ff8b1428495f8720693396c89e4ff7a725d21937e2fc95bbeb43
7
- data.tar.gz: 66135b6719c383bd0ff6a80e1ea7d13e0d1c5578a22c9b918fbe6904d52c8c3547ec1004df3e613a7e6503f6eeabdb8bc6181f2001a6182c0113de85f13a317c
6
+ metadata.gz: 83468266128639b7439119bd14099e9d8082a71edd5b738b6321651e44398aa0ccf40dded8f48b46d74469c570e0783982e5bef8ae7250ca4c2a1ca39bae6df6
7
+ data.tar.gz: 10b38d91004d40e2c8f71cec7de451e1295b447b592b91fd0ae8f0fc4053108eca59f788740fe44ca4af3eeb358f3337de9a85a2fc4f307d3297dede4fdc603a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2023-12-09
4
+
5
+ - Adds feature to automatically fetch the mutation object name to pre-select data
6
+
3
7
  ## [0.2.0] - 2023-12-09
4
8
 
5
9
  - Merges [PR #1](https://github.com/Idjent/shopify_api_bruv/pull/1) Fixes resource not being re-usable for mutations
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api_bruv (0.2.0)
4
+ shopify_api_bruv (0.2.1)
5
5
  httparty
6
6
  logger
7
7
 
@@ -9,26 +9,28 @@ module ShopifyApiBruv
9
9
 
10
10
  MAX_TRIES = ENV.fetch('SHOPIFY_API_BRUV_REQUEST_MAX_TRIES', 3).to_i
11
11
  SLEEP_TIMER = ENV.fetch('SHOPIFY_API_BRUV_REQUEST_SLEEP_TIMER', 4).to_i
12
+ MUTATION_OBJECT_NAME_PATTERN = /mutation\s+(\w+)\s*\(.*/
12
13
 
13
14
  def initialize(config:)
14
15
  @client = Clients::Graphql::Client.new(config:)
15
16
  end
16
17
 
17
- def request(variables: nil, mutation_object_name: nil, tries: 0)
18
+ def request(variables: nil, tries: 0)
18
19
  raise NotImplementedError, 'Please set a query in the derived class' if query.nil?
19
20
 
20
21
  response = client.request(query:, variables:)
21
22
 
22
- handle_response(response:, query:, variables:, mutation_object_name:, tries:)
23
+ handle_response(response:, query:, variables:, tries:)
23
24
  end
24
25
 
25
26
  private
26
27
 
27
- def handle_response(response:, query:, variables:, mutation_object_name:, tries:)
28
+ def handle_response(response:, query:, variables:, tries:)
28
29
  body = response.body
29
30
 
30
31
  handle_response_errors(body:, query:, variables:, tries:)
31
32
 
33
+ mutation_object_name = query.match(MUTATION_OBJECT_NAME_PATTERN)&.captures&.first
32
34
  mutation_object_name.nil? ? body['data'] : body.dig('data', mutation_object_name)
33
35
  end
34
36
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyApiBruv
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api_bruv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Idjent