Sha256: ca715f01ff160d72236ddd6c63fbdb5ed1402fd1eb817b90f0ba04b5bbcf79ab

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module ActionNetworkRest
  class EventCampaigns < Base
    attr_accessor :event_campaign_id

    # Without a event_campaign_id, this class is used for EventCampaign creation/update endpoints.
    # With a event_campaign_id, this class is used to initialise the Events class,
    # like client.event_campaigns(123).events
    def initialize(event_campaign_id = nil, client:)
      super(client: client, event_campaign_id: event_campaign_id)
    end

    def base_path
      'event_campaigns/'
    end

    def create(event_campaign_data)
      response = client.post_request(base_path, event_campaign_data)
      object_from_response(response)
    end

    def update(id, event_campaign_data)
      event_campaign_path = "#{base_path}#{url_escape(id)}"
      response = client.put_request event_campaign_path, event_campaign_data
      object_from_response(response)
    end

    def events(event_id = nil)
      @_events ||= ActionNetworkRest::Events.new(event_campaign_id: event_campaign_id, event_id: event_id,
                                                 client: client)
    end

    private

    def osdi_key
      'action_network:event_campaigns'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
action_network_rest-0.12.0 lib/action_network_rest/event_campaigns.rb
action_network_rest-1.0.1 lib/action_network_rest/event_campaigns.rb
action_network_rest-1.0.0 lib/action_network_rest/event_campaigns.rb
action_network_rest-0.11.0 lib/action_network_rest/event_campaigns.rb
action_network_rest-0.10.0 lib/action_network_rest/event_campaigns.rb
action_network_rest-0.9.0 lib/action_network_rest/event_campaigns.rb
action_network_rest-0.8.2 lib/action_network_rest/event_campaigns.rb
action_network_rest-0.8.1 lib/action_network_rest/event_campaigns.rb