lib/chartmogul/subscription.rb in chartmogul-ruby-1.2.2 vs lib/chartmogul/subscription.rb in chartmogul-ruby-1.3.0
- old
+ new
@@ -11,14 +11,13 @@
writeable_attr :data_source_uuid
readonly_attr :customer_uuid
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
+ def update_cancellation_dates(cancellation_dates_array)
+ cancellation_dates = parse_dates(cancellation_dates_array)
+ custom!(:patch, "/v1/import/subscriptions/#{uuid}", cancellation_dates: cancellation_dates)
end
def cancel(cancelled_at)
custom!(:patch, "/v1/import/subscriptions/#{uuid}", cancelled_at: cancelled_at)
end
@@ -28,9 +27,19 @@
custom!(:post, "/v1/customers/#{customer_uuid}/connect_subscriptions", subscriptions: subscriptions.map(&:serialize_for_write))
end
def self.all(customer_uuid, options = {})
Subscriptions.all(customer_uuid, options)
+ end
+
+ private
+
+ def set_cancellation_dates(cancellation_dates_array)
+ @cancellation_dates = parse_dates(cancellation_dates_array)
+ end
+
+ def parse_dates(dates)
+ dates.map { |date| Time.parse(date.to_s) }
end
end
class Subscriptions < APIResource
readonly_attr :customer_uuid