Sha256: 40f4c425461f2828c4d97048d576d8c8e4c8f9e8a811b2347edfbebecf5fe87c

Contents?: true

Size: 771 Bytes

Versions: 4

Compression:

Stored size: 771 Bytes

Contents

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

  request_method :post
  request_path { |_| '/groups.json' }
  request_body { |r| { 'group' => r.group_params } }

  def self.accepted_attributes
    %w(name)
  end

  def group_params
    @_group_params ||= Cistern::Hash.slice(params.fetch('group'), *self.class.accepted_attributes)
  end

  def mock(_params = {})
    identity = cistern.serial_id

    record = {
      'id'         => identity,
      'url'        => url_for("/groups/#{identity}.json"),
      'created_at' => timestamp,
      'updated_at' => timestamp,
      'deleted'    => false,
    }.merge(group_params)

    data[:groups][identity] = record

    mock_response({ 'group' => record }, { status: 201 })
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk2-1.15.0 lib/zendesk2/create_group.rb
zendesk2-1.13.1 lib/zendesk2/create_group.rb
zendesk2-1.13.0 lib/zendesk2/create_group.rb
zendesk2-1.12.0 lib/zendesk2/create_group.rb