Sha256: 966795ddd505f143f406e0f36bc055ac894a57cce52617f59e6ffcf2cf671cac

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require 'passworks/resource'

module Passworks

  # Represents a Pass of a given collection type Coupon, Boarding Pass, Event Ticket, Generic, Store Card
  #
  class PassResource < Resource

    # Deletes the current pass
    # @return [Boolean] True in case the pass is deleted
    def delete
      client.delete("#{collection_name}/#{collection_uuid}/passes/#{id}").ok?
    end

    # Sends a push notification to all clients with this pass installed
    # @return [Boolean] True in case the pass
    def push(options={})
      options = { body: options } unless options.empty?
      client.post("#{collection_name}/#{collection_uuid}/passes/#{id}/push", options).ok?
    end

    # Updates the {PassResource} and returns the updated instance
    # @return [PassResource] Updated instance
    def update(data, params={})
      content = {
        body: {
          pass: data
        }.merge(params)
      }
      response  = client.patch("#{collection_name}/#{collection_uuid}/passes/#{id}", content)
      self.class.new(client, collection_name, response.data)
    end

    private
      def collection_uuid
        @collection_uuid ||= campaign_id
      end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
passworks-2.0.7 lib/passworks/pass_resource.rb
passworks-2.0.6 lib/passworks/pass_resource.rb
passworks-2.0.5 lib/passworks/pass_resource.rb
passworks-2.0.4 lib/passworks/pass_resource.rb
passworks-2.0.3 lib/passworks/pass_resource.rb
passworks-2.0.2 lib/passworks/pass_resource.rb