Sha256: 565bf3779006ca7e975d8df8b4ebafc8701ab56253b138eb8024194116730772

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true
class Zendesk2::CreateBrand
  include Zendesk2::Request

  request_method :post
  request_path { |_| '/brands.json' }
  request_body { |r| { 'brand' => r.brand_params } }

  def self.accepted_attributes
    %w(name brand_url has_help_center help_center_state active default ticket_form_ids
       subdomain host_mapping signature_template)
  end

  def brand_params
    Cistern::Hash.slice(params.fetch('brand'), *self.class.accepted_attributes)
  end

  def mock
    identity = cistern.serial_id

    record = {
      'id'                   => identity,
      'name'                 => params['name'],
      'brand_url'            => '',
      'has_help_center'      => true,
      'help_center_state'    => true,
      'active'               => true,
      'end_user_visible'     => true,
      'default'              => false,
      'ticket_form_ids'      => params['ticket_form_ids'],
      'subdomain'            => params['subdomain'],
      'host_mapping'         => '',
      'signature_template'   => '',
      'url'                  => url_for("/brands/#{identity}.json"),
    }.merge(brand_params)

    data[:brands][identity] = record

    mock_response('brand' => record)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zendesk2-1.15.0 lib/zendesk2/create_brand.rb
zendesk2-1.13.1 lib/zendesk2/create_brand.rb
zendesk2-1.13.0 lib/zendesk2/create_brand.rb