Sha256: 301629efa417cd4ec0fe666b3bd7c73aa85a049ebf6cb695fe9b4f981a558d76

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module ChartMogul
  module Import
    class Subscription < APIResource
      set_resource_name 'Subscription'
      set_resource_path '/v1/import/customers/:customer_uuid/subscriptions'
      set_resource_root_key :subscriptions

      readonly_attr :uuid
      readonly_attr :external_id
      readonly_attr :cancellation_dates, default: []

      readonly_attr :plan_uuid
      readonly_attr :data_source_uuid
      writeable_attr :customer_uuid

      include API::Actions::All
      include API::Actions::Custom

      def set_cancellation_dates(cancellation_dates_array)
        @cancellation_dates = cancellation_dates_array.map do |cancellation_date|
          Time.parse(cancellation_date)
        end
      end

      def cancel(cancelled_at)
        custom!(:patch, "/v1/import/subscriptions/#{uuid}", cancelled_at: cancelled_at)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chartmogul-ruby-0.1.1 lib/chartmogul/import/subscription.rb