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

Parameters:

  • The parameters to create

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

Returns:

  • Created contact field object

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



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

Parameters:

  • The contact field ID

Returns:

  • nil

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



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

Parameters:

  • The contact field identifier

Returns:

  • Contact field object

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



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

Returns:

  • Array of contact field objects

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



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

Parameters:

  • The contact field ID

  • The parameters to update

Options Hash (options):

  • :name (String)

    The contact field name

  • :merge_tag (String)

    The merge tag of the field

Returns:

  • Updated contact field object

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



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