Module: Square::APIOperations::Create

Included in:
Category, Discount, Fee, Item, Refund, Variation
Defined in:
lib/square/api_operations/create.rb

Instance Method Summary collapse

Instance Method Details

#create(*args) ⇒ DataType

Create resource.

Parameters:

  • parent_id (String)

    ID of the ‘parent’ to update. Optional.

  • params (Hash)

    Payload. Optional.

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/square/api_operations/create.rb', line 10

def create(*args)
  if args.count == 1
    parent_id = nil
    params = args[0]
  elsif args.count == 2
    parent_id = args[0]
    params = args[1]
  end

  response = Square.make_request(
    method: 'POST',
    endpoint: self.generate_endpoint_url(nil, parent_id),
    payload: params
  )

  response = Square.parse_response(response)
  @data_type.new(response)
end