Sha256: 850d1fc86f77093d2a63a9c4da9345264e412c75a3adedcd001dcb42d4f35194

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module ChartMogul
  class SubscriptionEvent < APIResource
    set_resource_name 'SubscriptionEvent'
    set_resource_path '/v1/subscription_events'

    readonly_attr :id
    writeable_attr :data_source_uuid
    writeable_attr :customer_external_id
    writeable_attr :subscription_set_external_id
    writeable_attr :subscription_external_id
    writeable_attr :plan_external_id
    writeable_attr :event_date
    writeable_attr :effective_date
    writeable_attr :event_type
    writeable_attr :external_id
    readonly_attr :errors
    readonly_attr :created_at
    readonly_attr :updated_at
    writeable_attr :quantity
    writeable_attr :currency
    writeable_attr :amount_in_cents
    writeable_attr :tax_amount_in_cents
    writeable_attr :retracted_event_id

    include API::Actions::Custom
    include API::Actions::DestroyWithParams

    def self.all(options = {})
      SubscriptionEvents.all(options)
    end

    def create!
      custom!(:post, resource_path.path, subscription_event: instance_attributes)
    end

    def update!(attrs)
      custom!(:patch, resource_path.path, subscription_event: attrs.merge(id: instance_attributes[:id]))
    end

    def destroy!
      handling_errors do
        connection.delete(resource_path.path, subscription_event: { id: instance_attributes[:id] })
      end
    end
  end

  class SubscriptionEvents < APIResource
    set_resource_name 'SubscriptionEvents'
    set_resource_path '/v1/subscription_events'

    set_resource_root_key :subscription_events

    writeable_attr :meta

    include API::Actions::All
    include Concerns::Entries

    set_entry_class SubscriptionEvent
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chartmogul-ruby-3.2.0 lib/chartmogul/subscription_event.rb
chartmogul-ruby-3.1.0 lib/chartmogul/subscription_event.rb
chartmogul-ruby-3.0.2 lib/chartmogul/subscription_event.rb