Class: Mailtrap::ContactFieldsAPI

Inherits:
Object
  • Object
show all
Includes:
BaseAPI
Defined in:
lib/mailtrap/contact_fields_api.rb

Instance Attribute Summary

Attributes included from BaseAPI

#account_id, #client

Instance Method Summary collapse

Methods included from BaseAPI

included, #initialize

Instance Method Details

#create(options) ⇒ ContactField

Creates a new contact field

Options Hash (options):

  • :name (String)

    The contact field name

  • :data_type (String)

    The data type of the field

  • :merge_tag (String)

    The merge tag of the field

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

  • If invalid options are provided

Parameters:

  • The parameters to create

Returns:

  • Created contact field object



30
31
32
# File 'lib/mailtrap/contact_fields_api.rb', line 30

def create(options)
  base_create(options)
end

#delete(field_id) ⇒ Object

Deletes a contact field

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

Parameters:

  • The contact field ID

Returns:

  • nil



50
51
52
# File 'lib/mailtrap/contact_fields_api.rb', line 50

def delete(field_id)
  base_delete(field_id)
end

#get(field_id) ⇒ ContactField

Retrieves a specific contact field

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

Parameters:

  • The contact field identifier

Returns:

  • Contact field object



18
19
20
# File 'lib/mailtrap/contact_fields_api.rb', line 18

def get(field_id)
  base_get(field_id)
end

#listArray<ContactField>

Lists all contact fields for the account

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

Returns:

  • Array of contact field objects



57
58
59
# File 'lib/mailtrap/contact_fields_api.rb', line 57

def list
  base_list
end

#update(field_id, options) ⇒ ContactField

Updates an existing contact field

Options Hash (options):

  • :name (String)

    The contact field name

  • :merge_tag (String)

    The merge tag of the field

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

  • If invalid options are provided

Parameters:

  • The contact field ID

  • The parameters to update

Returns:

  • Updated contact field object



42
43
44
# File 'lib/mailtrap/contact_fields_api.rb', line 42

def update(field_id, options)
  base_update(field_id, options, i[name merge_tag])
end