Sha256: 342eda189b5bb72a4634ed1a8f48e99582a7eebde7ada7211d23db6359ae85d2
Contents?: true
Size: 567 Bytes
Versions: 4
Compression:
Stored size: 567 Bytes
Contents
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
4 entries across 4 versions & 1 rubygems