Sha256: a24c2f339d06d29d8b258119836e0e47578694433d210a5b1c5f460be667990b

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Iyzipay
  module Model
    module V2
      class Product < IyzipayResourceV2
        RESOURCE = '/v2/subscription/products'

        def list(options)
          header = get_http_header(options, RESOURCE)
          HttpClient.get_even_on_error(base_url(options), header)
        end

        def create(request, options)
          data = request.to_json
          header = get_http_header(options, RESOURCE, data)
          HttpClient.post_even_on_error(base_url(options), header, data)
        end

        def update(request, options)
          data = request.to_json
          path = path_for_action(request[:productReferenceCode])
          header = get_http_header(options, path, data)
          HttpClient.post_even_on_error(base_url(options, path), header, data)
        end

        private

        def base_url(options, path = RESOURCE)
          "#{options.base_url}#{path}"
        end

        def path_for_action(*path_args)
          "#{RESOURCE}#{'/' + path_args.join('/')}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
iyzipay-subscription-payments-1.0.2 lib/iyzipay/model/v2/product.rb
iyzipay-subscription-payments-1.0.1 lib/iyzipay/model/v2/product.rb
iyzipay-subscriptions-1.0.1 lib/iyzipay/model/v2/product.rb
iyzipay-subscriptions-1.0.0 lib/iyzipay/model/v2/product.rb