Sha256: b78ecb868c2357fcc67f35c4d17780a37af1be82cb9762ee9a94122f6e772a78

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module TranslationCms
  module Api
    module Customers
      module AffiliateProgram
        class Member < Base
          custom_endpoint :profile, on: :collection, request_method: :get
          custom_endpoint :confirm, on: :collection, request_method: :post
          custom_endpoint :resend, on: :collection, request_method: :post

          custom_endpoint :update_member, path: nil, on: :collection, request_method: :put

          AVAILABLE_STATES = %w[pending verified registered declined].freeze

          protected

          def method_missing_with_state_query(method, *args, &block)
            if method.to_s =~ /^(#{AVAILABLE_STATES.join('|')})\?$/
              q = method.to_s.gsub(/\?$/, '')
              state.to_s.casecmp(q) == 0
            else
              method_missing_without_state_query method, *args, &block
            end
          end
          alias_method_chain :method_missing, :state_query
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 lib/translation_cms/api/customers/affiliate_program/member.rb