Class: EPlat::Woocommerce::Shop
- Defined in:
- lib/e_plat/resource/platform_specific/woocommerce/shop.rb
Constant Summary
Constants inherited from Base
Constants included from Concerns::GraphQLable
Concerns::GraphQLable::FILTER_ARGS, Concerns::GraphQLable::QUERY_ARG_ARGS
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Concerns::Aliases
Class Method Summary collapse
-
.find_single(scope, options) ⇒ Object
Custom find_single for WooCommerce, since it uses settings/general endpoint.
Instance Method Summary collapse
Methods inherited from Shop
Methods inherited from Base
cached_shopify_webhook?, client, #client, element_name_plural?, exclude_from_json, #formatted_id, #graphql_input, #headers, #include_root_in_json, inherited, #initialize, initialize_singleton!, #mapped?, #native_keys, platform_specific_class?, prefix=, #read_only?, #string_to_consistent_id
Methods included from Countable
Methods included from Concerns::GraphQLable
#graphql_mutation_string, #mutate_graphql, #remove_mutation_root_from
Methods included from Concerns::Aliases
Methods included from Concerns::FullJson
Methods included from Concerns::OverwriteRequestMethods
#collection_path, #element_path, included, #initialize
Methods included from Concerns::OverwriteInstanceMethods
#as_eplat_json, #as_json, #create, #create_resource_for, #to_eplat_json, #to_json, #update
Constructor Details
This class inherits a constructor from EPlat::Base
Class Method Details
.find_single(scope, options) ⇒ Object
Custom find_single for WooCommerce, since it uses settings/general endpoint
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/shop.rb', line 5 def find_single(scope, ) , = ([:params]) path = "#{client.url_prefix}settings/general" # The response is an array, so we need to wrap it in a hash with a top-level key response = connection.get(path, client.headers) response_data = format.decode(response.body) # Process response data to create a hash with expected structure response_hash = {} if response_data.is_a?(Array) response_data.each do |setting| key = setting["id"] response_hash[key] = setting if key end end instantiate_record(response_hash, ) end |
Instance Method Details
#lazy_load_weight_unit ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/e_plat/resource/platform_specific/woocommerce/shop.rb', line 26 def lazy_load_weight_unit return @lazy_load_weight_unit if @lazy_load_weight_unit path = "#{client.url_prefix}settings/products/woocommerce_weight_unit" response = connection.get(path, client.headers) response_data = JSON.parse(response.body) @lazy_load_weight_unit = response_data["value"] || response_data["default"] end |