class Fastly::ContactApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/fastly/api/contact_api.rb, line 17
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

create_contacts(opts = {}) click to toggle source

Add a new customer contact Create a contact. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @option opts [String] :user_id The alphanumeric string representing the user for this customer contact. @option opts [String] :contact_type The type of contact. @option opts [String] :name The name of this contact, when user_id is not provided. @option opts [String] :email The email of this contact, when a user_id is not provided. @option opts [String] :phone The phone number for this contact. Required for primary, technical, and security contact types. @option opts [String] :customer_id The alphanumeric string representing the customer for this customer contact. @return [ContactResponse]

# File lib/fastly/api/contact_api.rb, line 30
def create_contacts(opts = {})
  data, _status_code, _headers = create_contacts_with_http_info(opts)
  data
end
create_contacts_with_http_info(opts = {}) click to toggle source

Add a new customer contact Create a contact. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @option opts [String] :user_id The alphanumeric string representing the user for this customer contact. @option opts [String] :contact_type The type of contact. @option opts [String] :name The name of this contact, when user_id is not provided. @option opts [String] :email The email of this contact, when a user_id is not provided. @option opts [String] :phone The phone number for this contact. Required for primary, technical, and security contact types. @option opts [String] :customer_id The alphanumeric string representing the customer for this customer contact. @return [Array<(ContactResponse, Integer, Hash)>] ContactResponse data, response status code and response headers

# File lib/fastly/api/contact_api.rb, line 45
def create_contacts_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactApi.create_contacts ...'
  end
  # unbox the parameters from the hash
  customer_id = opts[:'customer_id']
  # verify the required parameter 'customer_id' is set
  if @api_client.config.client_side_validation && customer_id.nil?
    fail ArgumentError, "Missing the required parameter 'customer_id' when calling ContactApi.create_contacts"
  end
  allowable_values = ["primary", "billing", "technical", "security", "emergency", "general compliance"]
  if @api_client.config.client_side_validation && opts[:'contact_type'] && !allowable_values.include?(opts[:'contact_type'])
    fail ArgumentError, "invalid value for \"contact_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/customer/{customer_id}/contacts'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['user_id'] = opts[:'user_id'] if !opts[:'user_id'].nil?
  form_params['contact_type'] = opts[:'contact_type'] if !opts[:'contact_type'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['email'] = opts[:'email'] if !opts[:'email'].nil?
  form_params['phone'] = opts[:'phone'] if !opts[:'phone'].nil?
  form_params['customer_id'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ContactResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"ContactApi.create_contacts",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContactApi#create_contacts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
delete_contact(opts = {}) click to toggle source

Delete a contact Delete a contact. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @option opts [String] :contact_id An alphanumeric string identifying the customer contact. (required) @return [InlineResponse200]

# File lib/fastly/api/contact_api.rb, line 115
def delete_contact(opts = {})
  data, _status_code, _headers = delete_contact_with_http_info(opts)
  data
end
delete_contact_with_http_info(opts = {}) click to toggle source

Delete a contact Delete a contact. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @option opts [String] :contact_id An alphanumeric string identifying the customer contact. (required) @return [Array<(InlineResponse200, Integer, Hash)>] InlineResponse200 data, response status code and response headers

# File lib/fastly/api/contact_api.rb, line 125
def delete_contact_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactApi.delete_contact ...'
  end
  # unbox the parameters from the hash
  customer_id = opts[:'customer_id']
  contact_id = opts[:'contact_id']
  # verify the required parameter 'customer_id' is set
  if @api_client.config.client_side_validation && customer_id.nil?
    fail ArgumentError, "Missing the required parameter 'customer_id' when calling ContactApi.delete_contact"
  end
  # verify the required parameter 'contact_id' is set
  if @api_client.config.client_side_validation && contact_id.nil?
    fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactApi.delete_contact"
  end
  # resource path
  local_var_path = '/customer/{customer_id}/contacts/{contact_id}'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s)).sub('{' + 'contact_id' + '}', CGI.escape(contact_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'InlineResponse200'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"ContactApi.delete_contact",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContactApi#delete_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
list_contacts(opts = {}) click to toggle source

List contacts List all contacts from a specified customer ID. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @return [Array<SchemasContactResponse>]

# File lib/fastly/api/contact_api.rb, line 184
def list_contacts(opts = {})
  data, _status_code, _headers = list_contacts_with_http_info(opts)
  data
end
list_contacts_with_http_info(opts = {}) click to toggle source

List contacts List all contacts from a specified customer ID. @option opts [String] :customer_id Alphanumeric string identifying the customer. (required) @return [Array<(Array<SchemasContactResponse>, Integer, Hash)>] Array<SchemasContactResponse> data, response status code and response headers

# File lib/fastly/api/contact_api.rb, line 193
def list_contacts_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactApi.list_contacts ...'
  end
  # unbox the parameters from the hash
  customer_id = opts[:'customer_id']
  # verify the required parameter 'customer_id' is set
  if @api_client.config.client_side_validation && customer_id.nil?
    fail ArgumentError, "Missing the required parameter 'customer_id' when calling ContactApi.list_contacts"
  end
  # resource path
  local_var_path = '/customer/{customer_id}/contacts'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<SchemasContactResponse>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"ContactApi.list_contacts",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContactApi#list_contacts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end