Sha256: 72cd6d89660bf5599de16c3216d8de85157ba2664643c0fd326bdbd30cf8fe39

Contents?: true

Size: 905 Bytes

Versions: 7

Compression:

Stored size: 905 Bytes

Contents

require 'vng/availability'

module Vng
  # Provides methods to interact with Vonigo locks.
  class Lock < Resource
    PATH = '/api/v1/resources/availability/'

    attr_reader :id

    def initialize(id:)
      @id = id
    end

    def self.create(duration:, location_id:, date:, minutes:, route_id:)
      body = {
        method: '2',
        serviceTypeID: '14', # only create items of serviceType 'Pet Grooming'
        duration: [duration.to_i, 30].max, # or 'duration is not supplied'
        locationID: location_id,
        dayID: date.strftime('%Y%m%d'),
        routeID: route_id,
        startTime: minutes,
      }

      data = request path: Vng::Availability::PATH, body: body

      new id: data['Ids']['lockID']
    end

    # def destroy
    #   body = {
    #     method: '4',
    #     lockID: id,
    #   }
    #
    #   self.class.request path: PATH, body: body
    # end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vng-1.2.0 lib/vng/lock.rb
vng-1.1.0 lib/vng/lock.rb
vng-1.0.0 lib/vng/lock.rb
vng-0.1.20 lib/vng/lock.rb
vng-0.1.19 lib/vng/lock.rb
vng-0.1.18 lib/vng/lock.rb
vng-0.1.17 lib/vng/lock.rb