lelylan-rb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -2
- data/Gemfile +1 -3
- data/Guardfile +1 -1
- data/README.md +155 -84
- data/Rakefile +2 -15
- data/images/bg_hr.png +0 -0
- data/images/blacktocat.png +0 -0
- data/images/icon_download.png +0 -0
- data/images/sprite_download.png +0 -0
- data/index.html +74 -0
- data/javascripts/main.js +1 -0
- data/lelylan_rb.gemspec +12 -13
- data/lib/lelylan/client.rb +20 -23
- data/lib/lelylan/client/device.rb +121 -0
- data/lib/lelylan/client/function.rb +73 -0
- data/lib/lelylan/client/history.rb +28 -0
- data/lib/lelylan/client/location.rb +62 -0
- data/lib/lelylan/client/physical.rb +34 -0
- data/lib/lelylan/client/profile.rb +17 -0
- data/lib/lelylan/client/property.rb +75 -0
- data/lib/lelylan/client/status.rb +74 -0
- data/lib/lelylan/client/subscription.rb +62 -0
- data/lib/lelylan/client/type.rb +73 -0
- data/lib/lelylan/configuration.rb +4 -4
- data/lib/lelylan/connection.rb +9 -2
- data/lib/lelylan/request.rb +2 -16
- data/lib/lelylan/version.rb +1 -1
- data/spec/fixtures/profile.json +8 -0
- data/spec/fixtures/subscription.json +10 -0
- data/spec/fixtures/subscriptions.json +10 -0
- data/spec/lelylan/client/device_spec.rb +234 -0
- data/spec/lelylan/client/function_spec.rb +158 -0
- data/spec/lelylan/client/history_spec.rb +48 -0
- data/spec/lelylan/client/location_spec.rb +122 -0
- data/spec/lelylan/client/physical_spec.rb +27 -0
- data/spec/lelylan/client/profile_spec.rb +27 -0
- data/spec/lelylan/client/property_spec.rb +159 -0
- data/spec/lelylan/client/status_spec.rb +158 -0
- data/spec/lelylan/client/subscription_spec.rb +144 -0
- data/spec/lelylan/client/type_spec.rb +158 -0
- data/spec/lelylan/oauth2_spec.rb +13 -19
- data/stylesheets/pygment_trac.css +70 -0
- data/stylesheets/stylesheet.css +431 -0
- metadata +75 -114
- data/lib/lelylan/client/categories.rb +0 -112
- data/lib/lelylan/client/consumptions.rb +0 -93
- data/lib/lelylan/client/devices.rb +0 -211
- data/lib/lelylan/client/functions.rb +0 -118
- data/lib/lelylan/client/histories.rb +0 -42
- data/lib/lelylan/client/locations.rb +0 -92
- data/lib/lelylan/client/properties.rb +0 -115
- data/lib/lelylan/client/statuses.rb +0 -110
- data/lib/lelylan/client/types.rb +0 -109
- data/spec/lelylan/client/categories_spec.rb +0 -178
- data/spec/lelylan/client/consumptions_spec.rb +0 -150
- data/spec/lelylan/client/devices_spec.rb +0 -342
- data/spec/lelylan/client/functions_spec.rb +0 -184
- data/spec/lelylan/client/histories_spec.rb +0 -64
- data/spec/lelylan/client/locations_spec.rb +0 -155
- data/spec/lelylan/client/properties_spec.rb +0 -184
- data/spec/lelylan/client/statuses_spec.rb +0 -184
- data/spec/lelylan/client/types_spec.rb +0 -184
@@ -1,92 +0,0 @@
|
|
1
|
-
module Lelylan
|
2
|
-
class Client
|
3
|
-
module Locations
|
4
|
-
|
5
|
-
# Public: Returns extended information for a given location identified from its URI.
|
6
|
-
# Find more at {http://dev.lelylan.com/rest/locations/#get Lelylan Dev Center}.
|
7
|
-
#
|
8
|
-
# location - A String that represent the location URI.
|
9
|
-
#
|
10
|
-
# Returns Hashie The location.
|
11
|
-
#
|
12
|
-
# Examples
|
13
|
-
#
|
14
|
-
# location = "http://api.lelylan.com/location/4dcb9e23d033a9088902200a"
|
15
|
-
# client.location(location)
|
16
|
-
#
|
17
|
-
def location(location)
|
18
|
-
get("/locations/#{find_id(location)}")
|
19
|
-
end
|
20
|
-
|
21
|
-
# Public: Returns extended information for a given location identified from its URI.
|
22
|
-
# Find more at {http://dev.lelylan.com/rest/locations/#all Lelylan Dev Center}.
|
23
|
-
#
|
24
|
-
# options - The Hash option used to refine the search (default: {}).
|
25
|
-
# Check out the {http://dev.lelylan.com/rest/locations/#all API doc} for the accepted options.
|
26
|
-
#
|
27
|
-
# Returns Hashie List of locations.
|
28
|
-
#
|
29
|
-
# Examples
|
30
|
-
#
|
31
|
-
# # Retrurns the first 10 locations
|
32
|
-
# client.locations(per: 10)
|
33
|
-
#
|
34
|
-
# # Returns the device locations from yesterday till now
|
35
|
-
# client.locations(type: 'room')
|
36
|
-
#
|
37
|
-
def locations(options = {})
|
38
|
-
get("/locations", options)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Public: Create a location and returns extended information for it.
|
42
|
-
# Find more at {http://dev.lelylan.com/rest/locations/#create Lelylan Dev Center}.
|
43
|
-
#
|
44
|
-
# options - The Hash option used to create the resource (default: {}).
|
45
|
-
# Check out the {http://dev.lelylan.com/rest/location/#create API doc} for the accepted options.
|
46
|
-
#
|
47
|
-
# Returns Hashie The created location.
|
48
|
-
#
|
49
|
-
# Examples
|
50
|
-
#
|
51
|
-
# client.create_location(name: 'Kids bedroom', type: 'room')
|
52
|
-
#
|
53
|
-
def create_location(options = {})
|
54
|
-
post("/locations", options)
|
55
|
-
end
|
56
|
-
|
57
|
-
# Public: Update a location identified from its URI and returns extended information for it.
|
58
|
-
# Find more at {http://dev.lelylan.com/rest/locations/#update Lelylan Dev Center}.
|
59
|
-
#
|
60
|
-
# location - A String that represent the location URI.
|
61
|
-
# options - The Hash option used to update the resource (default: {}).
|
62
|
-
# Check out the {http://dev.lelylan.com/rest/locations/#update API doc} for the accepted options.
|
63
|
-
#
|
64
|
-
# Returns Hashie The updated location.
|
65
|
-
#
|
66
|
-
# Examples
|
67
|
-
#
|
68
|
-
# location = "http://api.lelylan.com/locations/4dcb9e23d033a9088902200a"
|
69
|
-
# client.update_location(location, name: 'Big mama bedroom')
|
70
|
-
#
|
71
|
-
def update_location(location, options = {})
|
72
|
-
put("/locations/#{find_id(location)}", options)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Public: Delete a location identified from its URI and returns extended information for it.
|
76
|
-
# Find more at {http://dev.lelylan.com/rest/locations/#delete Lelylan Dev Center}.
|
77
|
-
#
|
78
|
-
# location - A String that represent the location URI.
|
79
|
-
#
|
80
|
-
# Returns Hashie The deleted location.
|
81
|
-
#
|
82
|
-
# Examples
|
83
|
-
#
|
84
|
-
# location = "http://api.lelyla.com/locations/4dcb9e23d033a9088902200a"
|
85
|
-
# client.delete_location(location)
|
86
|
-
#
|
87
|
-
def delete_location(location)
|
88
|
-
delete("/locations/#{find_id(location)}")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
module Lelylan
|
2
|
-
class Client
|
3
|
-
module Properties
|
4
|
-
|
5
|
-
# Public: Returns extended information for a given property identified from its URI.
|
6
|
-
# Find more at {http://dev.lelylan.com/rest/types/properties/#get Lelylan Dev Center}.
|
7
|
-
#
|
8
|
-
# property - A String that represent the property URI.
|
9
|
-
#
|
10
|
-
# Returns Hashie The property.
|
11
|
-
#
|
12
|
-
# Examples
|
13
|
-
#
|
14
|
-
# property = "http://api.lelylan.com/properties/4dcb9e23d033a9088902200a"
|
15
|
-
# client.property(property)
|
16
|
-
#
|
17
|
-
def property(property)
|
18
|
-
get("/properties/#{find_id(property)}")
|
19
|
-
end
|
20
|
-
|
21
|
-
# Public: Returns a list of properties.
|
22
|
-
# Find more at {http://dev.lelylan.com/rest/types/properties/#all Lelylan Dev Center}.
|
23
|
-
#
|
24
|
-
# options - The Hash option used to refine the search (default: {}).
|
25
|
-
# Check out the {http://dev.lelylan.com/rest/types/properties/#all API doc} for the accepted options.
|
26
|
-
#
|
27
|
-
# Returns Hashie List of properties.
|
28
|
-
#
|
29
|
-
# Examples
|
30
|
-
#
|
31
|
-
# # Retrurns the first 10 properties
|
32
|
-
# client.properties(per: 10)
|
33
|
-
#
|
34
|
-
# # Returns the properties where the name match with the desired string
|
35
|
-
# client.properties(name: 'Intensity')
|
36
|
-
#
|
37
|
-
def properties(options = {})
|
38
|
-
get("/properties", options)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Public: Returns a list of properties.
|
42
|
-
# Find more at {http://dev.lelylan.com/rest/properties/properties/#all Lelylan Dev Center}.
|
43
|
-
#
|
44
|
-
# options - The Hash option used to refine the search (default: {}).
|
45
|
-
# Check out the {http://dev.lelylan.com/rest/properties/properties/#all API doc} for the accepted options.
|
46
|
-
#
|
47
|
-
# Returns Hashie List of properties.
|
48
|
-
#
|
49
|
-
# Examples
|
50
|
-
#
|
51
|
-
# # Retrurns the first 10 properties
|
52
|
-
# client.properties(per: 10)
|
53
|
-
#
|
54
|
-
# # Returns the properties where the name match with the desired string
|
55
|
-
# client.properties(name: 'Intensity')
|
56
|
-
#
|
57
|
-
def public_properties(options = {})
|
58
|
-
get("/properties/public", options)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Public: Create a property and returns extended information for it.
|
62
|
-
# Find more at {http://dev.lelylan.com/rest/types/properties/#create Lelylan Dev Center}.
|
63
|
-
#
|
64
|
-
# options - The Hash option used to create the resource (default: {}).
|
65
|
-
# Check out the {http://dev.lelylan.com/rest/types/properties/#create API doc} for the accepted options.
|
66
|
-
#
|
67
|
-
# Returns Hashie The created property.
|
68
|
-
#
|
69
|
-
# Examples
|
70
|
-
#
|
71
|
-
# values = 1..100.to_a # [0, 1, 2, 3, 4, ..., 99, 100]
|
72
|
-
# client.create_property(name: 'Intensity', default: '0', values: values)
|
73
|
-
#
|
74
|
-
def create_property(options = {})
|
75
|
-
post("/properties", options)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Public: Update a property identified from its URI and returns extended information for it.
|
79
|
-
# Find more at {http://dev.lelylan.com/rest/types/properties/#update Lelylan Dev Center}.
|
80
|
-
#
|
81
|
-
# property - A String that represents the property URI.
|
82
|
-
# options - The Hash option used to update the resource (default: {}).
|
83
|
-
# Check out the {http://dev.lelylan.com/rest/types/properties/#update API doc} for the accepted options.
|
84
|
-
#
|
85
|
-
# Returns Hashie The updated property.
|
86
|
-
#
|
87
|
-
# Examples
|
88
|
-
#
|
89
|
-
# property = "http://api.lelylan.com/properties/4dcb9e23d033a9088902200a"
|
90
|
-
# client.update_property(property, default: '100')
|
91
|
-
#
|
92
|
-
def update_property(property, options = {})
|
93
|
-
put("/properties/#{find_id(property)}", options)
|
94
|
-
end
|
95
|
-
|
96
|
-
# Public: Delete a property identified from its URI and returns extended information for it.
|
97
|
-
# Find more at {http://dev.lelylan.com/rest/types/properties/#delete Lelylan Dev Center}.
|
98
|
-
#
|
99
|
-
# property - A String that represent the property URI.
|
100
|
-
#
|
101
|
-
# Returns Hashie The deleted property.
|
102
|
-
#
|
103
|
-
# Examples
|
104
|
-
#
|
105
|
-
# property = "http://api.lelylan.com/properties/4dcb9e23d033a9088902200a"
|
106
|
-
# client.delete_property(property)
|
107
|
-
#
|
108
|
-
def delete_property(property)
|
109
|
-
delete("/properties/#{find_id(property)}")
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module Lelylan
|
2
|
-
class Client
|
3
|
-
module Statuses
|
4
|
-
|
5
|
-
# Public: Returns extended information for a given status identified from its URI.
|
6
|
-
# Find more at {http://dev.lelylan.com/rest/types/statuses/#get Lelylan Dev Center}.
|
7
|
-
#
|
8
|
-
# status - A String that represent the status URI.
|
9
|
-
#
|
10
|
-
# Returns Hashie The status.
|
11
|
-
#
|
12
|
-
# Examples
|
13
|
-
#
|
14
|
-
# status = "http://api.lelylan.com/statuses/4dcb9e23d033a9088902200a"
|
15
|
-
# client.status(status)
|
16
|
-
#
|
17
|
-
def status(status)
|
18
|
-
get("/statuses/#{find_id(status)}")
|
19
|
-
end
|
20
|
-
|
21
|
-
# Public: Returns a list of statuses.
|
22
|
-
# Find more at {http://dev.lelylan.com/rest/types/statuses/#all Lelylan Dev Center}.
|
23
|
-
#
|
24
|
-
# options - The Hash option used to refine the search (default: {}).
|
25
|
-
# Check out the {http://dev.lelylan.com/rest/types/statuses/#all API doc} for the accepted options.
|
26
|
-
#
|
27
|
-
# Returns Hashie List of statuses.
|
28
|
-
#
|
29
|
-
# Examples
|
30
|
-
#
|
31
|
-
# # Retrurns the first 10 statuses
|
32
|
-
# client.statuses(per: 10)
|
33
|
-
#
|
34
|
-
# # Returns the statuses where the name match with the desired string
|
35
|
-
# client.statuses(name: 'Setting')
|
36
|
-
#
|
37
|
-
def statuses(options = {})
|
38
|
-
get("/statuses", options)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Public: Returns a list of all public statuses.
|
42
|
-
# Find more at {http://dev.lelylan.com/rest/statuses/core/#all Lelylan Dev Center}.
|
43
|
-
#
|
44
|
-
# options - The Hash option used to refine the search (default: {}).
|
45
|
-
# Check out the {http://dev.lelylan.com/rest/devices/statuses/#all API doc} for the accepted options.
|
46
|
-
#
|
47
|
-
# Returns Hashie List of statuses.
|
48
|
-
#
|
49
|
-
# Examples
|
50
|
-
#
|
51
|
-
# # Retrurns the first 10 public statuses
|
52
|
-
# client.public_statuses(per: 10)
|
53
|
-
#
|
54
|
-
def public_statuses(options = {})
|
55
|
-
get("/statuses/public", options)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Public: Create a status and returns extended information for it.
|
59
|
-
# Find more at {http://dev.lelylan.com/rest/types/statuses/#create Lelylan Dev Center}.
|
60
|
-
#
|
61
|
-
# options - The Hash option used to create the resource (default: {}).
|
62
|
-
# Check out the {http://dev.lelylan.com/rest/types/statuses/#create API doc} for the accepted options.
|
63
|
-
#
|
64
|
-
# Returns Hashie The created status.
|
65
|
-
#
|
66
|
-
# Examples
|
67
|
-
#
|
68
|
-
# client.create_status(name: 'Setting status')
|
69
|
-
#
|
70
|
-
def create_status(options = {})
|
71
|
-
post("/statuses", options)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Public: Update a status identified from its URI and returns extended information for it.
|
75
|
-
# Find more at {http://dev.lelylan.com/rest/types/statuses/#update Lelylan Dev Center}.
|
76
|
-
#
|
77
|
-
# status - A String that represents the status URI.
|
78
|
-
# options - The Hash option used to update the resource (default: {}).
|
79
|
-
# Check out the {http://dev.lelylan.com/rest/types/statuses/#update API doc} for the accepted options.
|
80
|
-
#
|
81
|
-
# Returns Hashie The updated status.
|
82
|
-
#
|
83
|
-
# Examples
|
84
|
-
#
|
85
|
-
# status = "http://api.lelylan.com/statuses/4dcb9e23d033a9088902200a"
|
86
|
-
# client.update_status(status, pending: true)
|
87
|
-
#
|
88
|
-
def update_status(status, options = {})
|
89
|
-
put("/statuses/#{find_id(status)}", options)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Public: Delete a status identified from its URI and returns extended information for it.
|
93
|
-
# Find more at {http://dev.lelylan.com/rest/types/statuses/#delete Lelylan Dev Center}.
|
94
|
-
#
|
95
|
-
# status - A String that represent the status URI.
|
96
|
-
#
|
97
|
-
# Returns Hashie The deleted status.
|
98
|
-
#
|
99
|
-
# Examples
|
100
|
-
#
|
101
|
-
# status = "http://api.lelylan.com/statuses/4dcb9e23d033a9088902200a"
|
102
|
-
# client.delete_status(status)
|
103
|
-
#
|
104
|
-
def delete_status(status)
|
105
|
-
delete("/statuses/#{find_id(status)}")
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
data/lib/lelylan/client/types.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
module Lelylan
|
2
|
-
class Client
|
3
|
-
module Types
|
4
|
-
|
5
|
-
# Public: Returns extended information for a given type identified from its URI.
|
6
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#get Lelylan Dev Center}.
|
7
|
-
#
|
8
|
-
# type - A String that represent the type URI.
|
9
|
-
#
|
10
|
-
# Returns Hashie The type.
|
11
|
-
#
|
12
|
-
# Examples
|
13
|
-
#
|
14
|
-
# type = "http://api.lelylan.com/types/4dcb9e23d033a9088902200a"
|
15
|
-
# client.type(type)
|
16
|
-
#
|
17
|
-
def type(type)
|
18
|
-
get("/types/#{find_id(type)}")
|
19
|
-
end
|
20
|
-
|
21
|
-
# Public: Returns a list of owned types.
|
22
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#all Lelylan Dev Center}.
|
23
|
-
#
|
24
|
-
# options - The Hash option used to refine the search (default: {}).
|
25
|
-
# Check out the {http://dev.lelylan.com/rest/devices/types/#all API doc} for the accepted options.
|
26
|
-
#
|
27
|
-
# Returns Hashie List of types.
|
28
|
-
#
|
29
|
-
# Examples
|
30
|
-
#
|
31
|
-
# # Retrurns the first 10 types
|
32
|
-
# client.types(per: 10)
|
33
|
-
#
|
34
|
-
# # Returns the types where the name match with the desired string
|
35
|
-
# client.types(name: 'dimmer')
|
36
|
-
#
|
37
|
-
def types(options = {})
|
38
|
-
get("/types", options)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Public: Returns a list of all public types.
|
42
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#all Lelylan Dev Center}.
|
43
|
-
#
|
44
|
-
# options - The Hash option used to refine the search (default: {}).
|
45
|
-
# Check out the {http://dev.lelylan.com/rest/devices/types/#all API doc} for the accepted options.
|
46
|
-
#
|
47
|
-
# Returns Hashie List of types.
|
48
|
-
#
|
49
|
-
# Examples
|
50
|
-
#
|
51
|
-
# # Retrurns the first 10 public types
|
52
|
-
# client.public_types(per: 10)
|
53
|
-
#
|
54
|
-
def public_types(options = {})
|
55
|
-
get("/types/public", options)
|
56
|
-
end
|
57
|
-
|
58
|
-
# Public: Create a type and returns extended information for it.
|
59
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#create Lelylan Dev Center}.
|
60
|
-
#
|
61
|
-
# options - The Hash option used to create the resource (default: {}).
|
62
|
-
# Check out the {http://dev.lelylan.com/rest/types/core/#create API doc} for the accepted options.
|
63
|
-
#
|
64
|
-
# Returns Hashie The created type.
|
65
|
-
#
|
66
|
-
# Examples
|
67
|
-
#
|
68
|
-
# client.create_type(name: 'Dimmer')
|
69
|
-
#
|
70
|
-
def create_type(options = {})
|
71
|
-
post("/types", options)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Public: Update a type identified from its URI and returns extended information for it.
|
75
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#update Lelylan Dev Center}.
|
76
|
-
#
|
77
|
-
# type - A String that represents the type URI.
|
78
|
-
# options - The Hash option used to update the resource (default: {}).
|
79
|
-
# Check out the {http://dev.lelylan.com/rest/types/core/#update API doc} for the accepted options.
|
80
|
-
#
|
81
|
-
# Returns Hashie The updated type.
|
82
|
-
#
|
83
|
-
# Examples
|
84
|
-
#
|
85
|
-
# type = "http://api.lelylan.com/types/4dcb9e23d033a9088902200a"
|
86
|
-
# client.update_type(type, name: 'RGB Dimmer')
|
87
|
-
#
|
88
|
-
def update_type(type, options = {})
|
89
|
-
put("/types/#{find_id(type)}", options)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Public: Delete a type identified from its URI and returns extended information for it.
|
93
|
-
# Find more at {http://dev.lelylan.com/rest/types/core/#delete Lelylan Dev Center}.
|
94
|
-
#
|
95
|
-
# type - A String that represent the type URI.
|
96
|
-
#
|
97
|
-
# Returns Hashie The deleted type.
|
98
|
-
#
|
99
|
-
# Examples
|
100
|
-
#
|
101
|
-
# type = "http://api.lelylan.com/types/4dcb9e23d033a9088902200a"
|
102
|
-
# client.delete_type(type)
|
103
|
-
#
|
104
|
-
def delete_type(type)
|
105
|
-
delete("/types/#{find_id(type)}")
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Lelylan::Client::Categories do
|
4
|
-
|
5
|
-
let(:client) do
|
6
|
-
a_client
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.category' do
|
10
|
-
|
11
|
-
let(:path) do
|
12
|
-
'/categories/4dcb9e23d033a9088900000a'
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:uri) do
|
16
|
-
"http://api.lelylan.com/#{path}"
|
17
|
-
end
|
18
|
-
|
19
|
-
before do
|
20
|
-
stub_get(path).to_return(body: fixture('category.json'))
|
21
|
-
end
|
22
|
-
|
23
|
-
let!(:category) do
|
24
|
-
client.category(uri)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'returns the category' do
|
28
|
-
category.uri.should_not be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sends the request' do
|
32
|
-
a_get(path).should have_been_made
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.categories' do
|
37
|
-
|
38
|
-
let(:path) do
|
39
|
-
'/categories'
|
40
|
-
end
|
41
|
-
|
42
|
-
before do
|
43
|
-
stub_get('/categories').to_return(body: fixture('categories.json'))
|
44
|
-
end
|
45
|
-
|
46
|
-
let!(:categories) do
|
47
|
-
client.categories
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'returns a list of categories' do
|
51
|
-
categories.should have(1).item
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'sends the request' do
|
55
|
-
a_get(path).should have_been_made
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with params' do
|
59
|
-
|
60
|
-
before do
|
61
|
-
stub_get(path).with(query: {per: '25'}).to_return(body: fixture('category.json'))
|
62
|
-
end
|
63
|
-
|
64
|
-
before do
|
65
|
-
client.categories(per: 25)
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'sends the params' do
|
69
|
-
a_get(path).with(query: {per: '25'}).should have_been_made
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '.public_categories' do
|
75
|
-
|
76
|
-
let(:path) do
|
77
|
-
'/categories/public'
|
78
|
-
end
|
79
|
-
|
80
|
-
before do
|
81
|
-
client.user = nil
|
82
|
-
client.password = nil
|
83
|
-
end
|
84
|
-
|
85
|
-
before do
|
86
|
-
stub_get(path).to_return(body: fixture('categories.json'))
|
87
|
-
end
|
88
|
-
|
89
|
-
let!(:categories) do
|
90
|
-
client.public_categories
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'returns a list of categories' do
|
94
|
-
categories.should have(1).item
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'sends the request' do
|
98
|
-
a_get('http://api.lelylan.com/categories/public').should have_been_made
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '.create_category' do
|
103
|
-
|
104
|
-
let(:path) do
|
105
|
-
'/categories'
|
106
|
-
end
|
107
|
-
|
108
|
-
before do
|
109
|
-
stub_post(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('category.json'))
|
110
|
-
end
|
111
|
-
|
112
|
-
let!(:category) do
|
113
|
-
client.create_category(name: 'Dimmer')
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'returns the category' do
|
117
|
-
category.uri.should_not be_nil
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'sends the request' do
|
121
|
-
a_post(path).with(body: {name: 'Dimmer'}).should have_been_made
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe '.update_category' do
|
126
|
-
|
127
|
-
let(:path) do
|
128
|
-
'/categories/4dcb9e23d033a9088900000a'
|
129
|
-
end
|
130
|
-
|
131
|
-
let(:uri) do
|
132
|
-
"http://api.lelylan.com/#{path}"
|
133
|
-
end
|
134
|
-
|
135
|
-
before do
|
136
|
-
stub_put(path).with(body: {name: 'Dimmer'}).to_return(body: fixture('category.json'))
|
137
|
-
end
|
138
|
-
|
139
|
-
let!(:category) do
|
140
|
-
client.update_category(uri, name: 'Dimmer')
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'returns the category' do
|
144
|
-
category.uri.should_not be_nil
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'sends the request' do
|
148
|
-
a_put(path).with(body: {name: 'Dimmer'}).should have_been_made
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe '.delete_category' do
|
153
|
-
|
154
|
-
let(:path) do
|
155
|
-
'/categories/4dcb9e23d033a9088900000a'
|
156
|
-
end
|
157
|
-
|
158
|
-
let(:uri) do
|
159
|
-
"http://api.lelylan.com/#{path}"
|
160
|
-
end
|
161
|
-
|
162
|
-
before do
|
163
|
-
stub_delete(path).to_return(body: fixture('category.json'))
|
164
|
-
end
|
165
|
-
|
166
|
-
let!(:category) do
|
167
|
-
client.delete_category(uri)
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'returns the category' do
|
171
|
-
category.uri.should_not be_nil
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'sends the request' do
|
175
|
-
a_delete(path).should have_been_made
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|