Sha256: 3357d18df75331aec7722cbcc336f6001c762f63f6ca6b287e7b7afdc15b3107

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module ShopifyApiBruv
  module Clients
    module Rest
      class Client
        attr_reader :config, :http_client

        def initialize(config:)
          @config = config
          @http_client = HttpClient.new(config:, path: "admin/api/#{config.api_version}")
        end

        def get(path:, body: nil, query: nil, headers: nil)
          request(method: :get, path:, body:, query:, headers:)
        end

        def delete(path:, body: nil, query: nil, headers: nil)
          request(method: :delete, path:, body:, query:, headers:)
        end

        def put(path:, body:, query: nil, headers: nil)
          request(method: :put, path:, body:, query:, headers:)
        end

        def post(path:, body:, query: nil, headers: nil)
          request(method: :post, path:, body:, query:, headers:)
        end

        private

        def request(method:, path:, body:, query:, headers:)
          http_client.request(
            http_request: HttpRequest.new(
              method:,
              path:,
              body:,
              content_type: body.nil? ? nil : 'application/json',
              headers:
            )
          )
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shopify_api_bruv-0.2.5 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.2.4 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.2.3 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.2.2 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.2.1 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.2.0 lib/shopify_api_bruv/clients/rest/client.rb
shopify_api_bruv-0.1.0 lib/shopify_api_bruv/clients/rest/client.rb