Class: Vng::Availability
Overview
Provides methods to interact with Vonigo availabilities.
Constant Summary collapse
- PATH =
 '/api/v1/resources/availability/'
Instance Attribute Summary collapse
- 
  
    
      #date  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute date.
 - 
  
    
      #minutes  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute minutes.
 - 
  
    
      #route_id  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute route_id.
 
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #initialize(route_id:, date:, minutes:)  ⇒ Availability 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Availability.
 
Constructor Details
#initialize(route_id:, date:, minutes:) ⇒ Availability
Returns a new instance of Availability.
      10 11 12 13 14  | 
    
      # File 'lib/vng/availability.rb', line 10 def initialize(route_id:, date:, minutes:) @route_id = route_id @date = date @minutes = minutes end  | 
  
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
      8 9 10  | 
    
      # File 'lib/vng/availability.rb', line 8 def date @date end  | 
  
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
      8 9 10  | 
    
      # File 'lib/vng/availability.rb', line 8 def minutes @minutes end  | 
  
#route_id ⇒ Object (readonly)
Returns the value of attribute route_id.
      8 9 10  | 
    
      # File 'lib/vng/availability.rb', line 8 def route_id @route_id end  | 
  
Class Method Details
.where(location_id:, duration:, from_time:, to_time:) ⇒ Object
      16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  | 
    
      # File 'lib/vng/availability.rb', line 16 def self.where(location_id:, duration:, from_time:, to_time:) body = { method: '0', serviceTypeID: '14', # only return items of serviceType 'Pet Grooming' locationID: location_id, duration: [duration.to_i, 30].max, # or 'duration is not provided' dateStart: from_time.to_i, dateEnd: to_time.to_i, } data = request path: PATH, body: body data['Availability'].map do |availability| route_id = availability['routeID'] date = Date.strptime availability['dayID'], '%Y%m%d' minutes = availability['startTime'].to_i new route_id: route_id, date: date, minutes: minutes end end  |