lib/kentaa/api/resources/newsletter_subscription.rb in kentaa-api-0.2.1 vs lib/kentaa/api/resources/newsletter_subscription.rb in kentaa-api-0.3.0

- old
+ new

@@ -1,27 +1,22 @@ # frozen_string_literal: true module Kentaa module Api module Resources - class NewsletterSubscription < Base - include Kentaa::Api::Resources::Resource - + class NewsletterSubscription < Resource def object_key "NewsletterSubscription_#{id}" end def entity if project_id - client = Kentaa::Api::Clients::Projects.new(config) - client.get(project_id) + Kentaa::Api::Resources::Project.new(config, id: project_id) elsif segment_id - client = Kentaa::Api::Clients::Segments.new(config) - client.get(segment_id) + Kentaa::Api::Resources::Segment.new(config, id: segment_id) else - client = Kentaa::Api::Clients::Sites.new(config) - client.current + Kentaa::Api::Resources::Site.new(config, id: site_id) end end def first_name data[:first_name] @@ -62,10 +57,16 @@ def subscription_url data[:subscription_url] end def consent - @consent ||= Kentaa::Api::Resources::Consent.new(config, data[:consent]) if data[:consent] + @consent ||= Kentaa::Api::Resources::Consent.new(config, data: data[:consent]) if data[:consent] + end + + protected + + def load_resource(options) + request.get("/newsletter-subscriptions/#{id}", options) end end end end end