Skip to content

Commit

Permalink
update to latest server JSON schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Williams committed Apr 24, 2015
1 parent 29b1351 commit 3f687e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
12 changes: 2 additions & 10 deletions sdk/server/ruby/att/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ class Html5SdkApp < Sinatra::Base
$host.slice!(/\/$/)
end

#disable SSL verification if enableSSLCheck is set to false
enableSSLCheck = $config['enableSSLCheck']
if(!enableSSLCheck)
# @private
I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
end

$client_token = nil

# @private
Expand Down Expand Up @@ -97,9 +89,7 @@ def initialize_current_client_token()
begin
oauth_service = Auth::OAuthService.new($host, $client_id, $client_secret)
$client_token = oauth_service.refreshToken($client_token)
puts "Refreshed the client token..."
rescue Exception => e
puts "Exception occurred... #{e}"
get_client_credentials()
end
end
Expand Down Expand Up @@ -168,6 +158,8 @@ def get_current_consent_token(scope)
end

before '/att/*' do
puts "initializing client token"
initialize_current_client_token() unless request.path == '/att/showTokens'
puts "client token: #{$client_token.access_token}"
end
end
2 changes: 1 addition & 1 deletion sdk/server/ruby/att/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class Html5SdkListener < Sinatra::Base
end
stored_notifications = JSON.parse(file_contents)

subscriptions_from_request = body['notification']['subscriptions']
subscriptions_from_request = body['messageNotifications']['subscriptionNotifications']
subscriptions_from_request.each do |subscription|
subscription_id = subscription['subscriptionId']
stored_notifications_for_subscription = stored_notifications[subscription_id]
Expand Down
6 changes: 3 additions & 3 deletions sdk/server/ruby/att/services/notification_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def channel_id
$notification_channel = svc.createMIMNotificationChannel('application/json')
rescue Att::Codekit::Service::ServiceException => ex
errorInfo = JSON.parse(ex.message)
unless errorInfo['RequestError'] && errorInfo['RequestError']['MessageId'] && errorInfo['RequestError']['MessageId'] == 'POL1001'
unless errorInfo['RequestError'] && errorInfo['RequestError']['PolicyException'] && errorInfo['RequestError']['PolicyException']['MessageId'] && errorInfo['RequestError']['PolicyException']['MessageId'] == 'POL1001'
raise
end
# 'Variables' looks like 'channelId:mychannelid'; the third partition contains 'mychannelid'
id = errorInfo['RequestError']['Variables'].partition(':')[2]
id = errorInfo['RequestError']['PolicyException']['Variables'].partition(':')[2].strip
$notification_channel = svc.getNotificationChannel(id)
end
end
Expand Down Expand Up @@ -255,4 +255,4 @@ def delete_notifications(subscription_id)
delete '/att/notification/v1/notifications' do
delete_notifications(session[:subscription_id])
end
end
end
6 changes: 5 additions & 1 deletion sdk/server/ruby/lib/codekit/service/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def getNotificationChannel(channel_id)
begin
r = self.get(url)
rescue RestClient::Exception => e
raise(ServiceException, e.response || e.message, e.backtrace)
# handle both of these cases: e.response is nil, or
# e.response is just whitespace (seen in practice).
error_text = e.response
error_text = e.message if error_text.to_s.strip.empty?
raise(ServiceException, error_text, e.backtrace)
end
Model::NotificationChannel.from_response(r)
end
Expand Down

0 comments on commit 3f687e3

Please sign in to comment.