Class: Vng::Route

Inherits:
Resource show all
Defined in:
lib/vng/route.rb

Overview

Provides methods to interact with Vonigo ZIP routes.

Constant Summary collapse

PATH =
'/api/v1/resources/Routes/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:) ⇒ Route

Returns a new instance of Route.



10
11
12
13
# File 'lib/vng/route.rb', line 10

def initialize(id:, name:)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/route.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/vng/route.rb', line 8

def name
  @name
end

Class Method Details

.allObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vng/route.rb', line 15

def self.all
  data = request path: PATH

  data['Routes'].filter do |route|
    route['isActive']
  end.map do |body|
    id = body['routeID']
    name = body['routeName']

    new id: id, name: name
  end
end