Skip to content

Commit 281bfd5

Browse files
committed
fix(orbility/parking_rest_api): improve error response
1 parent 6da15ac commit 281bfd5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/orbility/parking_rest_api.cr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ class Orbility::ParkingRestAPI < PlaceOS::Driver
118118

119119
def add_subscription(subscription : Subscription) : Int64?
120120
response = post("/subscriberinterface/api/Subscription/Add", headers: subscriber_auth, body: subscription.to_json)
121-
basic_check(response).id
121+
resp = basic_check(response)
122+
return resp.id if resp.success?
123+
nil
122124
end
123125

124126
def update_subscription(subscription : Subscription) : Bool
@@ -136,9 +138,11 @@ class Orbility::ParkingRestAPI < PlaceOS::Driver
136138
basic_check(response).success?
137139
end
138140

139-
def add_card(card : CardUpdate) : Int64?
141+
def add_card(card : CardUpdate) : Int64
140142
response = post("/subscriberinterface/api/Card/Add", headers: subscriber_auth, body: card.to_json)
141-
basic_check(response).id
143+
resp = basic_check(response)
144+
raise "add card failed with: #{resp.to_pretty_json}\nadding: #{card.to_json}" unless resp.success?
145+
resp.id
142146
end
143147

144148
def update_card(card : CardUpdate) : Bool

0 commit comments

Comments
 (0)