Class: Ecfr::SubscriptionsService::Subscription
- Defined in:
- lib/ecfr/subscriptions_service/subscription.rb
Constant Summary collapse
- SUBSCRIPTIONS_PATH =
"v1/subscriptions"
Constants inherited from Base
Base::SUPPORTED_ARRAY_ACCESSORS
Instance Attribute Summary collapse
-
#created_at ⇒ Date
readonly
date the subscription was created.
-
#delivery_count ⇒ Integer
readonly
the number of times the subscription has been delivered.
-
#id ⇒ Integer
readonly
the subscription id.
-
#last_delivered_at ⇒ Date
readonly
last date this subscription had matches and was delivered.
-
#parameters ⇒ Hash
readonly
With “query”, and “hierarchy” keys.
-
#title ⇒ String
readonly
a description of the subscription.
Attributes inherited from Base
#metadata, #request_data, #response_status, #results
Class Method Summary collapse
-
.create_subscription(user_id, subscription_data) ⇒ <Subscription>
Create a subscription for a user.
-
.delete_subscription(user_id, token, subscription_id) ⇒ [<Subscription>, <Integer>]
Delete a subscription.
-
.get_subscriptions(user_id) ⇒ [<Subscription>]
Retrive a list of subscriptions for a user.
Methods inherited from Base
base_url, service_name, service_path
Methods inherited from Base
basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key
Methods included from Extensible
Methods included from AttributeMethodDefinition
Methods inherited from Client
build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge
Methods included from ParallelClient
Constructor Details
This class inherits a constructor from Ecfr::Base
Instance Attribute Details
#created_at ⇒ Date (readonly)
date the subscription was created
16 17 18 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 16 attribute :created_at, type: :date, desc: "date the subscription was created" |
#delivery_count ⇒ Integer (readonly)
the number of times the subscription has been delivered
9 10 11 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 9 attribute :delivery_count, type: :integer, desc: "the number of times the subscription has been delivered" |
#id ⇒ Integer (readonly)
the subscription id
12 13 14 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 12 attribute :id, type: :integer, desc: "the subscription id" |
#last_delivered_at ⇒ Date (readonly)
last date this subscription had matches and was delivered
19 20 21 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 19 attribute :last_delivered_at, type: :date, desc: "last date this subscription had matches and was delivered" |
#parameters ⇒ Hash (readonly)
Returns with “query”, and “hierarchy” keys.
26 27 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 26 attribute :parameters, desc: "the subscription search parameters" |
#title ⇒ String (readonly)
a description of the subscription
6 7 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 6 attribute :title, desc: "a description of the subscription" |
Class Method Details
.create_subscription(user_id, subscription_data) ⇒ <Subscription>
Create a subscription for a user
59 60 61 62 63 64 65 66 67 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 59 def self.create_subscription(user_id, subscription_data) perform( :post, "#{SUBSCRIPTIONS_PATH}/#{user_id}", params: subscription_data, client_options: , perform_options: {attributes_key: "subscription"} ) end |
.delete_subscription(user_id, token, subscription_id) ⇒ [<Subscription>, <Integer>]
Delete a subscription
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 78 def self.delete_subscription(user_id, token, subscription_id) unsubscribe_data = { token: token, user_id: user_id, subscription_id: subscription_id } subscription = perform( :delete, "#{SUBSCRIPTIONS_PATH}/unsubscribe", params: unsubscribe_data, client_options: , perform_options: {attributes_key: "subscription"} ) [subscription, subscription.response_status] end |
.get_subscriptions(user_id) ⇒ [<Subscription>]
Retrive a list of subscriptions for a user
38 39 40 41 42 43 44 |
# File 'lib/ecfr/subscriptions_service/subscription.rb', line 38 def self.get_subscriptions(user_id) perform( :get, "#{SUBSCRIPTIONS_PATH}/#{user_id}.json", client_options: ) end |