Class: Zaius::Event

Inherits:
APIResource show all
Defined in:
lib/zaius/event.rb

Constant Summary collapse

OBJECT_NAME =
"Event".freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIResource

class_name, #refresh, resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from ZaiusObject

#==, #[], #[]=, #as_json, construct_from, #deleted?, #dirty!, #each, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #refresh_from, #serialize_params, serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Zaius::ZaiusObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zaius::ZaiusObject

Class Method Details

.subscribe(list_id:, email:, params: {}, opts: {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/zaius/event.rb', line 5

def self.subscribe(list_id:, email:, params: {}, opts: {})
  list_ids = Array(list_id)

  body = list_ids.map do |list|
    data = {
      list_id: list
    }.merge(params)
    
    {
      type: "list",
      action: "subscribe",
      identifiers: { 
        email: email
      },
      data: data
    }
  end

  resp, opts = request(:post, resource_url, body, opts)

  ZaiusObject.construct_from(resp.data, opts)
end

Instance Method Details

#resource_urlObject



28
29
30
# File 'lib/zaius/event.rb', line 28

def resource_url
  "/events"
end