Class: ContextIO::Contact

Inherits:
Object
  • Object
show all
Includes:
CallHelpers
Defined in:
lib/context_io/account/contact.rb

Constant Summary collapse

CONTACT_READERS =
%I(emails name thumbnail last_received last_sent count sent_count
received_count sent_from_account_count query email resource_url)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CallHelpers

#build_url, #call_api_return_new_object, #call_api_return_updated_object, #delete, #get, #get_request, #parse_response, #return_post_api_call_made, #success?, #validate_params

Methods included from CollectionHelper

#collection_return, #contact_collection_return

Constructor Details

#initialize(parent:, identifier: nil, response: nil, status: nil, success: nil, api_call_made: nil) ⇒ Contact

Returns a new instance of Contact.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/context_io/account/contact.rb', line 13

def initialize(parent:,
               identifier: nil,
               response: nil,
               status: nil,
               success: nil,
               api_call_made: nil)
  @parent = parent
  @connection = parent.connection
  @email = identifier
  @status = status
  @success = success
  @api_call_made = api_call_made
  if response
    parse_response(response)
  end
end

Instance Attribute Details

#api_call_madeObject

Returns the value of attribute api_call_made.



10
11
12
# File 'lib/context_io/account/contact.rb', line 10

def api_call_made
  @api_call_made
end

Instance Method Details

#call_urlObject



34
35
36
# File 'lib/context_io/account/contact.rb', line 34

def call_url
  build_url("contacts", encoded_email)
end

#encoded_emailObject



30
31
32
# File 'lib/context_io/account/contact.rb', line 30

def encoded_email
  ERB::Util.url_encode(email)
end

#get_files(**kwargs) ⇒ Object



38
39
40
41
42
43
# File 'lib/context_io/account/contact.rb', line 38

def get_files(**kwargs)
  collection_return(url: "#{call_url}/files",
                    klass: Files,
                    valid_params: ValidGetParams::CONTACT_FILES,
                    given_params: kwargs)
end

#get_messages(**kwargs) ⇒ Object



45
46
47
48
49
50
# File 'lib/context_io/account/contact.rb', line 45

def get_messages(**kwargs)
  collection_return(url: "#{call_url}/messages",
                    klass: Message,
                    valid_params: ValidGetParams::CONTACT_MESSAGES,
                    given_params: kwargs)
end

#get_threads(**kwargs) ⇒ Object



52
53
54
55
56
57
# File 'lib/context_io/account/contact.rb', line 52

def get_threads(**kwargs)
  call_api_return_new_object(klass: Threads,
                             url: "#{call_url}/threads",
                             valid_params: ValidGetParams::THREADS,
                             given_params: kwargs)
end