Sha256: 61eb0678d6198fdb949338725d686f430d7dc5b694f0814d6dc44cc82e91073d
Contents?: true
Size: 598 Bytes
Versions: 1
Compression:
Stored size: 598 Bytes
Contents
# frozen_string_literal: true module LightspeedRestaurantClient module Operations module Create def create(attributes) response = LightspeedRestaurantClient.post(resource_path, attributes) payload = build_payload(attributes, response) return new(payload) if is_a?(Class) self.class.new(payload) end private def build_payload(attributes, response) JSON.parse(response) rescue JSON::ParserError => error raise error if response.to_i.zero? attributes.merge!(id: response.to_i) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lightspeed_restaurant-2.0.0 | lib/lightspeed_restaurant/operations/create.rb |