Sha256: 58e8ad324daf958563404940f3a363c227f376144db54b541cfb8bcfc02bd9d9

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 Bytes

Contents

module Centaman
  class Service::CostRate < Centaman::Service
    include Centaman::JsonWrapper
    attr_reader :first_name, :last_name, :email, :primary_member_id

    def after_init(args={})
      @first_name = args.fetch(:first_name, nil)
      @last_name = args.fetch(:last_name, nil)
      @email = args.fetch(:email, nil)
      @primary_member_id = args.fetch(:primary_member_id, nil)
    end

    def object_class
      Centaman::Object::CostRate
    end

    def endpoint
      '/ticket_services/TimedTicket'
    end

    def options
      super + [
        { key: 'FirstName', value: first_name },
        { key: 'LastName', value: last_name },
        { key: 'Email', value: email }
      ]
    end

    def build_objects(resp)
      return [] unless resp.respond_to?(:map)
      return build_object(resp) if resp.respond_to?(:merge)
      @tickets = resp.map do |ticket_hash|
        object_class.new(ticket_hash.merge(additional_hash_to_serialize_after_response))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
centaman-5.0.6 lib/centaman/service/cost_rate.rb