App42_Ruby_API 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +21 -0
 - data/App42_Ruby_API.gemspec +33 -0
 - data/Gemfile +3 -0
 - data/LICENSE.txt +22 -0
 - data/README.md +29 -0
 - data/Rakefile +1 -0
 - data/TODO.rb +3 -0
 - data/lib/App42_Ruby_API.rb +232 -0
 - data/lib/App42_Ruby_API/App42BadParameterException.rb +31 -0
 - data/lib/App42_Ruby_API/App42Exception.rb +39 -0
 - data/lib/App42_Ruby_API/App42LimitException.rb +15 -0
 - data/lib/App42_Ruby_API/App42NotFoundException.rb +15 -0
 - data/lib/App42_Ruby_API/App42Response.rb +13 -0
 - data/lib/App42_Ruby_API/App42ResponseBuilder.rb +67 -0
 - data/lib/App42_Ruby_API/App42SecurityException.rb +15 -0
 - data/lib/App42_Ruby_API/version.rb +3 -0
 - data/lib/connection/RESTConnection.rb +713 -0
 - data/lib/email/Email.rb +51 -0
 - data/lib/email/EmailMIME.rb +51 -0
 - data/lib/email/EmailResponseBuilder.rb +76 -0
 - data/lib/email/EmailService.rb +244 -0
 - data/lib/gallery/Album.rb +56 -0
 - data/lib/gallery/AlbumResponseBuilder.rb +168 -0
 - data/lib/gallery/AlbumService.rb +337 -0
 - data/lib/gallery/PhotoService.rb +591 -0
 - data/lib/game/Game.rb +39 -0
 - data/lib/game/GameResponseBuilder.rb +106 -0
 - data/lib/game/GameService.rb +268 -0
 - data/lib/game/Reward.rb +24 -0
 - data/lib/game/RewardResponseBuilder.rb +85 -0
 - data/lib/game/RewardService.rb +440 -0
 - data/lib/game/ScoreBoardService.rb +433 -0
 - data/lib/game/ScoreService.rb +157 -0
 - data/lib/geo/Geo.rb +51 -0
 - data/lib/geo/GeoPoint.rb +43 -0
 - data/lib/geo/GeoResponseBuilder.rb +145 -0
 - data/lib/geo/GeoService.rb +505 -0
 - data/lib/imageProcessor/Image.rb +42 -0
 - data/lib/imageProcessor/ImageProcessorResponseBuilder.rb +40 -0
 - data/lib/imageProcessor/ImageProcessorService.rb +1054 -0
 - data/lib/log/Log.rb +49 -0
 - data/lib/log/LogResponseBuilder.rb +61 -0
 - data/lib/log/LogService.rb +920 -0
 - data/lib/message/Queue.rb +50 -0
 - data/lib/message/QueueResponseBuilder.rb +64 -0
 - data/lib/message/QueueService.rb +469 -0
 - data/lib/push/DeviceType.rb +56 -0
 - data/lib/push/PushNotification.rb +38 -0
 - data/lib/push/PushNotificationResposneBuilder.rb +74 -0
 - data/lib/push/PushNotificationService.rb +458 -0
 - data/lib/recommend/PreferenceData.rb +25 -0
 - data/lib/recommend/Recommender.rb +48 -0
 - data/lib/recommend/RecommenderResponseBuilder.rb +70 -0
 - data/lib/recommend/RecommenderService.rb +1092 -0
 - data/lib/recommend/RecommenderSimilarity.rb +52 -0
 - data/lib/review/Review.rb +38 -0
 - data/lib/review/ReviewResponseBuilder.rb +76 -0
 - data/lib/review/ReviewService.rb +590 -0
 - data/lib/session/Session.rb +43 -0
 - data/lib/session/SessionResponseBuilder.rb +70 -0
 - data/lib/session/SessionService.rb +427 -0
 - data/lib/shopping/Cart.rb +77 -0
 - data/lib/shopping/CartResponseBuilder.rb +118 -0
 - data/lib/shopping/CartService.rb +902 -0
 - data/lib/shopping/Catalogue.rb +79 -0
 - data/lib/shopping/CatalogueResponseBuilder.rb +170 -0
 - data/lib/shopping/CatalogueService.rb +649 -0
 - data/lib/shopping/ItemData.rb +29 -0
 - data/lib/shopping/PaymentStatus.rb +60 -0
 - data/lib/social/Social.rb +35 -0
 - data/lib/social/SocialResponseBuilder.rb +38 -0
 - data/lib/social/SocialService.rb +585 -0
 - data/lib/storage/OrderByType.rb +29 -0
 - data/lib/storage/Query.rb +39 -0
 - data/lib/storage/QueryBuilder.rb +118 -0
 - data/lib/storage/Storage.rb +45 -0
 - data/lib/storage/StorageResponseBuilder.rb +86 -0
 - data/lib/storage/StorageService.rb +775 -0
 - data/lib/upload/Upload.rb +40 -0
 - data/lib/upload/UploadFileType.rb +83 -0
 - data/lib/upload/UploadResponseBuilder.rb +58 -0
 - data/lib/upload/UploadService.rb +960 -0
 - data/lib/user/User.rb +102 -0
 - data/lib/user/UserResponseBuilder.rb +105 -0
 - data/lib/user/UserService.rb +1209 -0
 - data/lib/util/util.rb +244 -0
 - data/question.rb +79 -0
 - metadata +204 -0
 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 2 
     | 
    
         
            +
            #  Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'connection/RESTConnection'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'util/util'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'json/pure'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
            #
         
     | 
| 
      
 11 
     | 
    
         
            +
            # This Session object is the value object which contains the properties of
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Session.
         
     | 
| 
      
 13 
     | 
    
         
            +
            #
         
     | 
| 
      
 14 
     | 
    
         
            +
            #
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            module App42
         
     | 
| 
      
 17 
     | 
    
         
            +
              module Session
         
     | 
| 
      
 18 
     | 
    
         
            +
                class Session < App42Response
         
     | 
| 
      
 19 
     | 
    
         
            +
                  attr_accessor :userName, :sessionId,:createdOn,:invalidatedOn,:attributeList
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  @userName
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @sessionId
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @createdOn
         
     | 
| 
      
 24 
     | 
    
         
            +
                  @invalidatedOn
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @attributeList = Array.new()
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                class Attribute
         
     | 
| 
      
 29 
     | 
    
         
            +
                  attr_accessor :name, :value
         
     | 
| 
      
 30 
     | 
    
         
            +
                  @name
         
     | 
| 
      
 31 
     | 
    
         
            +
                  @value
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  #
         
     | 
| 
      
 34 
     | 
    
         
            +
                  # This is a constructor that takes no parameter
         
     | 
| 
      
 35 
     | 
    
         
            +
                  #
         
     | 
| 
      
 36 
     | 
    
         
            +
                  #
         
     | 
| 
      
 37 
     | 
    
         
            +
                  def initialize(session)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    session.attributeList.push(self)
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,70 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 2 
     | 
    
         
            +
            #  Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'connection/RESTConnection'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'App42_Ruby_API/App42ResponseBuilder'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'util/util'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'json'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            module App42
         
     | 
| 
      
 11 
     | 
    
         
            +
              module Session
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                #
         
     | 
| 
      
 14 
     | 
    
         
            +
                #
         
     | 
| 
      
 15 
     | 
    
         
            +
                # SessionResponseBuilder class converts the JSON response retrieved from the
         
     | 
| 
      
 16 
     | 
    
         
            +
                # server to the value object i.e Session
         
     | 
| 
      
 17 
     | 
    
         
            +
                #
         
     | 
| 
      
 18 
     | 
    
         
            +
                #
         
     | 
| 
      
 19 
     | 
    
         
            +
                class SessionResponseBuilder < App42ResponseBuilder
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  #
         
     | 
| 
      
 22 
     | 
    
         
            +
                  # Converts the response in JSON format to the value object i.e Session
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # @param json
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #      - response in JSON format
         
     | 
| 
      
 26 
     | 
    
         
            +
                  #
         
     | 
| 
      
 27 
     | 
    
         
            +
                  # @return Session object filled with json data
         
     | 
| 
      
 28 
     | 
    
         
            +
                  #
         
     | 
| 
      
 29 
     | 
    
         
            +
                  #
         
     | 
| 
      
 30 
     | 
    
         
            +
                  def buildSessionResponse(json)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    sessionObj = Session.new
         
     | 
| 
      
 32 
     | 
    
         
            +
                    attributeList = Array.new()
         
     | 
| 
      
 33 
     | 
    
         
            +
                    sessionObj.attributeList = attributeList
         
     | 
| 
      
 34 
     | 
    
         
            +
                    sessionObj.strResponse = json
         
     | 
| 
      
 35 
     | 
    
         
            +
                    jsonObj = JSON.parse(json)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    jsonObjApp42 = jsonObj.fetch("app42")
         
     | 
| 
      
 37 
     | 
    
         
            +
                    jsonObjResponse = jsonObjApp42.fetch("response")
         
     | 
| 
      
 38 
     | 
    
         
            +
                    sessionObj.isResponseSuccess=(jsonObjResponse.fetch("success"))
         
     | 
| 
      
 39 
     | 
    
         
            +
                    jsonObjSession = jsonObjResponse.fetch("session")
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    buildObjectFromJSONTree(sessionObj,jsonObjSession)
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                    if jsonObjSession.has_key?("attributes") == false
         
     | 
| 
      
 44 
     | 
    
         
            +
                      return sessionObj
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    jsonObjAttributes = jsonObjSession.fetch("attributes")
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    if jsonObjAttributes.has_key?("attribute") == false
         
     | 
| 
      
 50 
     | 
    
         
            +
                      return sessionObj
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                    if jsonObjAttributes["attribute"].instance_of?(Hash)
         
     | 
| 
      
 53 
     | 
    
         
            +
                      # Only One attribute is there
         
     | 
| 
      
 54 
     | 
    
         
            +
                      jsonObjAttribute = jsonObjAttributes.fetch("attribute")
         
     | 
| 
      
 55 
     | 
    
         
            +
                      attribute = App42::Session::Attribute.new(sessionObj)
         
     | 
| 
      
 56 
     | 
    
         
            +
                      buildObjectFromJSONTree(attribute,jsonObjAttribute)
         
     | 
| 
      
 57 
     | 
    
         
            +
                    else
         
     | 
| 
      
 58 
     | 
    
         
            +
                      jsonObjAttributeArray = jsonObjAttributes.fetch("attribute")
         
     | 
| 
      
 59 
     | 
    
         
            +
                      jsonObjAttributeArray.length.times do |i|
         
     | 
| 
      
 60 
     | 
    
         
            +
                        # Get Individual Attribute Node and set it into Object
         
     | 
| 
      
 61 
     | 
    
         
            +
                        jsonObjAttribute = jsonObjAttributeArray[i]
         
     | 
| 
      
 62 
     | 
    
         
            +
                        attribute = App42::Session::Attribute.new(sessionObj)
         
     | 
| 
      
 63 
     | 
    
         
            +
                        buildObjectFromJSONTree(attribute,jsonObjAttribute)
         
     | 
| 
      
 64 
     | 
    
         
            +
                      end
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end
         
     | 
| 
      
 66 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,427 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 2 
     | 
    
         
            +
            #  Copyright © 2012 ShepHertz Technologies Pvt Ltd. All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # -----------------------------------------------------------------------
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'connection/RESTConnection'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'util/util'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'json/pure'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'App42_Ruby_API/App42Response'
         
     | 
| 
      
 10 
     | 
    
         
            +
            require 'session/SessionResponseBuilder'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'App42_Ruby_API/App42Exception'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'session/Session'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            module App42
         
     | 
| 
      
 15 
     | 
    
         
            +
              module Session
         
     | 
| 
      
 16 
     | 
    
         
            +
                #
         
     | 
| 
      
 17 
     | 
    
         
            +
                # The Session Manager manages user sessions on the server side. It is a persistent Session Manager.
         
     | 
| 
      
 18 
     | 
    
         
            +
                # It allows to save attributes in the session and retrieve them.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # This Session Manager is especially useful for Mobile/Device Apps which want to do
         
     | 
| 
      
 20 
     | 
    
         
            +
                # session management.
         
     | 
| 
      
 21 
     | 
    
         
            +
                #
         
     | 
| 
      
 22 
     | 
    
         
            +
                # @see Session
         
     | 
| 
      
 23 
     | 
    
         
            +
                #
         
     | 
| 
      
 24 
     | 
    
         
            +
                class SessionService
         
     | 
| 
      
 25 
     | 
    
         
            +
                  #
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # this is a constructor that takes
         
     | 
| 
      
 27 
     | 
    
         
            +
                  #
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # @param apiKey
         
     | 
| 
      
 29 
     | 
    
         
            +
                  # @param secretKey
         
     | 
| 
      
 30 
     | 
    
         
            +
                  # @param baseURL
         
     | 
| 
      
 31 
     | 
    
         
            +
                  #
         
     | 
| 
      
 32 
     | 
    
         
            +
                  def initialize(api_key, secret_key, base_url)
         
     | 
| 
      
 33 
     | 
    
         
            +
                    puts "Session Service->initialize"
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @api_key = api_key
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @secret_key = secret_key
         
     | 
| 
      
 36 
     | 
    
         
            +
                    @base_url = base_url
         
     | 
| 
      
 37 
     | 
    
         
            +
                    @resource = "session"
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @version = "1.0"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  #
         
     | 
| 
      
 42 
     | 
    
         
            +
                  # Create Session for the User. If the session does not exist it will create a new session
         
     | 
| 
      
 43 
     | 
    
         
            +
                  #
         
     | 
| 
      
 44 
     | 
    
         
            +
                  # @param uName
         
     | 
| 
      
 45 
     | 
    
         
            +
                  #      - Username for which the session has to be created.
         
     | 
| 
      
 46 
     | 
    
         
            +
                  #
         
     | 
| 
      
 47 
     | 
    
         
            +
                  # @return Session object containing the session id of the created session. This id has to be used for storing or
         
     | 
| 
      
 48 
     | 
    
         
            +
                  # retrieving attributes.
         
     | 
| 
      
 49 
     | 
    
         
            +
                  #
         
     | 
| 
      
 50 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 51 
     | 
    
         
            +
                  #
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def get_session(uName)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    puts "Get Session Called "
         
     | 
| 
      
 55 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 56 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 57 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 58 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 59 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 60 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(uName, "User Name");
         
     | 
| 
      
 61 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 62 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      body = {'app42' => {"session"=> {
         
     | 
| 
      
 64 
     | 
    
         
            +
                        "userName" => uName
         
     | 
| 
      
 65 
     | 
    
         
            +
                        }}}.to_json
         
     | 
| 
      
 66 
     | 
    
         
            +
                      puts "Body #{body}"
         
     | 
| 
      
 67 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 68 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 69 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 70 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 71 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 72 
     | 
    
         
            +
                      }
         
     | 
| 
      
 73 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 74 
     | 
    
         
            +
                      params.store("body", body)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 76 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 77 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}"
         
     | 
| 
      
 78 
     | 
    
         
            +
                      response = connection.post(signature, resource_url, query_params, body)
         
     | 
| 
      
 79 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 80 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 82 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 83 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 84 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    end
         
     | 
| 
      
 86 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 87 
     | 
    
         
            +
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  #
         
     | 
| 
      
 90 
     | 
    
         
            +
                  # Create User Session based on the isCreate boolean parameter.
         
     | 
| 
      
 91 
     | 
    
         
            +
                  # If isCreate is true and there is an existing session for the user, the existing session
         
     | 
| 
      
 92 
     | 
    
         
            +
                  # is returned. If there is no existing session for the user a new one is created.
         
     | 
| 
      
 93 
     | 
    
         
            +
                  # If isCreate is false and there is an existing session, the existing session is returned
         
     | 
| 
      
 94 
     | 
    
         
            +
                  # if there is no existing session new one is not created
         
     | 
| 
      
 95 
     | 
    
         
            +
                  #
         
     | 
| 
      
 96 
     | 
    
         
            +
                  # @param uName
         
     | 
| 
      
 97 
     | 
    
         
            +
                  #      - Username for which the session has to be created.
         
     | 
| 
      
 98 
     | 
    
         
            +
                  # @param isCreate
         
     | 
| 
      
 99 
     | 
    
         
            +
                  #      - A boolean value for specifying if an existing session is not there, should
         
     | 
| 
      
 100 
     | 
    
         
            +
                  # a new one is to be created or not.
         
     | 
| 
      
 101 
     | 
    
         
            +
                  #
         
     | 
| 
      
 102 
     | 
    
         
            +
                  # @return Session object containing the session id of the created session. This id has to be used for storing or
         
     | 
| 
      
 103 
     | 
    
         
            +
                  # retrieving attributes.
         
     | 
| 
      
 104 
     | 
    
         
            +
                  #
         
     | 
| 
      
 105 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 106 
     | 
    
         
            +
                  #
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                  def get_session_boolean(uName, isCreate)
         
     | 
| 
      
 109 
     | 
    
         
            +
                    puts "Get Session Boolean Called "
         
     | 
| 
      
 110 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 111 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 112 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 113 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 114 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 115 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(uName, "User Name");
         
     | 
| 
      
 116 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(isCreate, "Is Create");
         
     | 
| 
      
 117 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 118 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 119 
     | 
    
         
            +
                      body = {'app42' => {"session"=> {
         
     | 
| 
      
 120 
     | 
    
         
            +
                        "userName" => uName
         
     | 
| 
      
 121 
     | 
    
         
            +
                        }}}.to_json
         
     | 
| 
      
 122 
     | 
    
         
            +
                      puts "Body #{body}"
         
     | 
| 
      
 123 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 124 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 125 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 126 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 127 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 128 
     | 
    
         
            +
                      }
         
     | 
| 
      
 129 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 130 
     | 
    
         
            +
                      params.store("body", body)
         
     | 
| 
      
 131 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 132 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 133 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/#{isCreate}"
         
     | 
| 
      
 134 
     | 
    
         
            +
                      response = connection.post(signature, resource_url, query_params, body)
         
     | 
| 
      
 135 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 136 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 137 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 138 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 139 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 140 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 141 
     | 
    
         
            +
                    end
         
     | 
| 
      
 142 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 143 
     | 
    
         
            +
                  end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                  #
         
     | 
| 
      
 146 
     | 
    
         
            +
                  # Invalidate a session based on the session id. All the attributes store in the session will be lost.
         
     | 
| 
      
 147 
     | 
    
         
            +
                  #
         
     | 
| 
      
 148 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 149 
     | 
    
         
            +
                  #      - The session id for which the session has to be invalidated.
         
     | 
| 
      
 150 
     | 
    
         
            +
                  #
         
     | 
| 
      
 151 
     | 
    
         
            +
                  # @return App42Response if invalidated successfully
         
     | 
| 
      
 152 
     | 
    
         
            +
                  #
         
     | 
| 
      
 153 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 154 
     | 
    
         
            +
                  #
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
                  def invalidate(sessionId)
         
     | 
| 
      
 157 
     | 
    
         
            +
                    puts "In Validate Called "
         
     | 
| 
      
 158 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 159 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 160 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 161 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 162 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 163 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId, "Session Id");
         
     | 
| 
      
 164 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 165 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 166 
     | 
    
         
            +
                      body = {'app42' => {"session"=> {
         
     | 
| 
      
 167 
     | 
    
         
            +
                        "id" => sessionId
         
     | 
| 
      
 168 
     | 
    
         
            +
                        }}}.to_json
         
     | 
| 
      
 169 
     | 
    
         
            +
                      puts "Body #{body}"
         
     | 
| 
      
 170 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 171 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 172 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 173 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 174 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 175 
     | 
    
         
            +
                      }
         
     | 
| 
      
 176 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 177 
     | 
    
         
            +
                      params.store("body", body)
         
     | 
| 
      
 178 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 179 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 180 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}"
         
     | 
| 
      
 181 
     | 
    
         
            +
                      response = connection.put(signature, resource_url, query_params, body)
         
     | 
| 
      
 182 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 183 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 184 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 185 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 186 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 187 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 188 
     | 
    
         
            +
                    end
         
     | 
| 
      
 189 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 190 
     | 
    
         
            +
                  end
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
                  #
         
     | 
| 
      
 193 
     | 
    
         
            +
                  # Sets attribute in a session whose session id is provided. Attributes are stored in a key value pair.
         
     | 
| 
      
 194 
     | 
    
         
            +
                  #
         
     | 
| 
      
 195 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 196 
     | 
    
         
            +
                  #      - Session id for which the attribute has to be saved.
         
     | 
| 
      
 197 
     | 
    
         
            +
                  # @param attributeName
         
     | 
| 
      
 198 
     | 
    
         
            +
                  #      - The attribute key that needs to be stored
         
     | 
| 
      
 199 
     | 
    
         
            +
                  # @param attributeValue
         
     | 
| 
      
 200 
     | 
    
         
            +
                  #      - The attribute value that needs to be stored
         
     | 
| 
      
 201 
     | 
    
         
            +
                  #
         
     | 
| 
      
 202 
     | 
    
         
            +
                  # @return Session object containing the attribute and value which is stored
         
     | 
| 
      
 203 
     | 
    
         
            +
                  #
         
     | 
| 
      
 204 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 205 
     | 
    
         
            +
                  #
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
                  def set_attribute(sessionId,attributeName,attributeValue)
         
     | 
| 
      
 208 
     | 
    
         
            +
                    puts "Set Attribute Called "
         
     | 
| 
      
 209 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 210 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 211 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 212 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 213 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 214 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId, "Session Id");
         
     | 
| 
      
 215 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(attributeName, "Attribute Name");
         
     | 
| 
      
 216 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(attributeValue, "Attribute Value");
         
     | 
| 
      
 217 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 218 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 219 
     | 
    
         
            +
                      body = {'app42' => {"session"=> {
         
     | 
| 
      
 220 
     | 
    
         
            +
                        "name" => attributeName,
         
     | 
| 
      
 221 
     | 
    
         
            +
                        "value" => attributeValue
         
     | 
| 
      
 222 
     | 
    
         
            +
                        }}}.to_json
         
     | 
| 
      
 223 
     | 
    
         
            +
                      puts "Body #{body}"
         
     | 
| 
      
 224 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 225 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 226 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 227 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 228 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 229 
     | 
    
         
            +
                        'sessionId'=> sessionId
         
     | 
| 
      
 230 
     | 
    
         
            +
                      }
         
     | 
| 
      
 231 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 232 
     | 
    
         
            +
                      params.store("body", body)
         
     | 
| 
      
 233 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 234 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 235 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/id/#{sessionId}"
         
     | 
| 
      
 236 
     | 
    
         
            +
                      response = connection.post(signature, resource_url, query_params, body)
         
     | 
| 
      
 237 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 238 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 239 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 240 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 241 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 242 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 243 
     | 
    
         
            +
                    end
         
     | 
| 
      
 244 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 245 
     | 
    
         
            +
                  end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
                  #
         
     | 
| 
      
 248 
     | 
    
         
            +
                  # Gets the attribute value in a session whose session id is provided.
         
     | 
| 
      
 249 
     | 
    
         
            +
                  #
         
     | 
| 
      
 250 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 251 
     | 
    
         
            +
                  #      - The session id for which the attribute has to be fetched
         
     | 
| 
      
 252 
     | 
    
         
            +
                  # @param attributeName
         
     | 
| 
      
 253 
     | 
    
         
            +
                  #      - The attribute key that has to be fetched
         
     | 
| 
      
 254 
     | 
    
         
            +
                  #
         
     | 
| 
      
 255 
     | 
    
         
            +
                  # @return Session object containing  the attribute and value which is stored for the session id and attribute name
         
     | 
| 
      
 256 
     | 
    
         
            +
                  #
         
     | 
| 
      
 257 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 258 
     | 
    
         
            +
                  #
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                  def get_attribute(sessionId,attributeName)
         
     | 
| 
      
 261 
     | 
    
         
            +
                    puts "Get Attribute Called "
         
     | 
| 
      
 262 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 263 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 264 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 265 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 266 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 267 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId, "Session Id");
         
     | 
| 
      
 268 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(attributeName, "Attribute Name");
         
     | 
| 
      
 269 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 270 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 271 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 272 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 273 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 274 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 275 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 276 
     | 
    
         
            +
                      }
         
     | 
| 
      
 277 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 278 
     | 
    
         
            +
                      params.store("sessionId", sessionId);
         
     | 
| 
      
 279 
     | 
    
         
            +
                      params.store("name", attributeName)
         
     | 
| 
      
 280 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 281 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 282 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/id/#{sessionId}/#{attributeName}"
         
     | 
| 
      
 283 
     | 
    
         
            +
                      response = connection.get(signature, resource_url, query_params)
         
     | 
| 
      
 284 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 285 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 286 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 287 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 288 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 289 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 290 
     | 
    
         
            +
                    end
         
     | 
| 
      
 291 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 292 
     | 
    
         
            +
                  end
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
                  #
         
     | 
| 
      
 295 
     | 
    
         
            +
                  # Gets all the attributes for a given session id
         
     | 
| 
      
 296 
     | 
    
         
            +
                  #
         
     | 
| 
      
 297 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 298 
     | 
    
         
            +
                  #      - The session id for which the attribute has to be fetched
         
     | 
| 
      
 299 
     | 
    
         
            +
                  #
         
     | 
| 
      
 300 
     | 
    
         
            +
                  # @return Session object containing  all the attributes and values which are stored for the session id
         
     | 
| 
      
 301 
     | 
    
         
            +
                  #
         
     | 
| 
      
 302 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 303 
     | 
    
         
            +
                  #
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
                  def get_all_attribute(sessionId)
         
     | 
| 
      
 306 
     | 
    
         
            +
                    puts "Get All Attributes Called "
         
     | 
| 
      
 307 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 308 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 309 
     | 
    
         
            +
                    sessionObj = nil
         
     | 
| 
      
 310 
     | 
    
         
            +
                    sessionObj = Session.new()
         
     | 
| 
      
 311 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 312 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId,"Session Id")
         
     | 
| 
      
 313 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 314 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 315 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 316 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 317 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 318 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 319 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 320 
     | 
    
         
            +
                      }
         
     | 
| 
      
 321 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 322 
     | 
    
         
            +
                      params.store("sessionId", sessionId);
         
     | 
| 
      
 323 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 324 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 325 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/id/#{sessionId}"
         
     | 
| 
      
 326 
     | 
    
         
            +
                      response = connection.get(signature, resource_url, query_params)
         
     | 
| 
      
 327 
     | 
    
         
            +
                      session = SessionResponseBuilder.new
         
     | 
| 
      
 328 
     | 
    
         
            +
                      sessionObj = session.buildSessionResponse(response)
         
     | 
| 
      
 329 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 330 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 331 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 332 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 333 
     | 
    
         
            +
                    end
         
     | 
| 
      
 334 
     | 
    
         
            +
                    return sessionObj
         
     | 
| 
      
 335 
     | 
    
         
            +
                  end
         
     | 
| 
      
 336 
     | 
    
         
            +
             
     | 
| 
      
 337 
     | 
    
         
            +
                  #
         
     | 
| 
      
 338 
     | 
    
         
            +
                  # Removes the  attribute from a session whose session id is provided.
         
     | 
| 
      
 339 
     | 
    
         
            +
                  #
         
     | 
| 
      
 340 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 341 
     | 
    
         
            +
                  #      - The session id for which the attribute has to be removed
         
     | 
| 
      
 342 
     | 
    
         
            +
                  # @param attributeName
         
     | 
| 
      
 343 
     | 
    
         
            +
                  #      - The attribute key that has to be removed
         
     | 
| 
      
 344 
     | 
    
         
            +
                  #
         
     | 
| 
      
 345 
     | 
    
         
            +
                  # @return App42Response if removed successfully
         
     | 
| 
      
 346 
     | 
    
         
            +
                  #
         
     | 
| 
      
 347 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 348 
     | 
    
         
            +
                  #
         
     | 
| 
      
 349 
     | 
    
         
            +
             
     | 
| 
      
 350 
     | 
    
         
            +
                  def remove_attribute(sessionId,attributeName)
         
     | 
| 
      
 351 
     | 
    
         
            +
                    puts "Remove Attribute Called "
         
     | 
| 
      
 352 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 353 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 354 
     | 
    
         
            +
                    responseObj = App42Response.new();
         
     | 
| 
      
 355 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 356 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId, "Session Id");
         
     | 
| 
      
 357 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(attributeName, "Attribute Name");
         
     | 
| 
      
 358 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 359 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 360 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 361 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 362 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 363 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 364 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 365 
     | 
    
         
            +
                      }
         
     | 
| 
      
 366 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 367 
     | 
    
         
            +
                      params.store("sessionId", sessionId)
         
     | 
| 
      
 368 
     | 
    
         
            +
                      params.store("name", attributeName)
         
     | 
| 
      
 369 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 370 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 371 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/id/#{sessionId}/#{attributeName}"
         
     | 
| 
      
 372 
     | 
    
         
            +
                      response = connection.delete(signature, resource_url, query_params)
         
     | 
| 
      
 373 
     | 
    
         
            +
                      responseObj.strResponse=(response)
         
     | 
| 
      
 374 
     | 
    
         
            +
                      responseObj.isResponseSuccess=(true)
         
     | 
| 
      
 375 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 376 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 377 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 378 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 379 
     | 
    
         
            +
                    end
         
     | 
| 
      
 380 
     | 
    
         
            +
                    return responseObj
         
     | 
| 
      
 381 
     | 
    
         
            +
                  end
         
     | 
| 
      
 382 
     | 
    
         
            +
             
     | 
| 
      
 383 
     | 
    
         
            +
                  #
         
     | 
| 
      
 384 
     | 
    
         
            +
                  # Removes all the attributes for a given session id
         
     | 
| 
      
 385 
     | 
    
         
            +
                  #
         
     | 
| 
      
 386 
     | 
    
         
            +
                  # @param sessionId
         
     | 
| 
      
 387 
     | 
    
         
            +
                  #      - The session id for which the attributes has to be removed
         
     | 
| 
      
 388 
     | 
    
         
            +
                  #
         
     | 
| 
      
 389 
     | 
    
         
            +
                  # @return App42Response if removed successfully
         
     | 
| 
      
 390 
     | 
    
         
            +
                  #
         
     | 
| 
      
 391 
     | 
    
         
            +
                  # @raise App42Exception
         
     | 
| 
      
 392 
     | 
    
         
            +
                  #
         
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
                  def remove_all_attribute(sessionId)
         
     | 
| 
      
 395 
     | 
    
         
            +
                    puts "Remove All Attributes Called "
         
     | 
| 
      
 396 
     | 
    
         
            +
                    puts "Base url #{@base_url}"
         
     | 
| 
      
 397 
     | 
    
         
            +
                    response = nil
         
     | 
| 
      
 398 
     | 
    
         
            +
                    responseObj = App42Response.new();
         
     | 
| 
      
 399 
     | 
    
         
            +
                    util = Util.new
         
     | 
| 
      
 400 
     | 
    
         
            +
                    util.throwExceptionIfNullOrBlank(sessionId, "Session Id");
         
     | 
| 
      
 401 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 402 
     | 
    
         
            +
                      connection = App42::Connection::RESTConnection.new(@base_url)
         
     | 
| 
      
 403 
     | 
    
         
            +
                      query_params = Hash.new
         
     | 
| 
      
 404 
     | 
    
         
            +
                      params = {
         
     | 
| 
      
 405 
     | 
    
         
            +
                        'apiKey'=> @api_key,
         
     | 
| 
      
 406 
     | 
    
         
            +
                        'version' => @version,
         
     | 
| 
      
 407 
     | 
    
         
            +
                        'timeStamp' => util.get_timestamp_utc,
         
     | 
| 
      
 408 
     | 
    
         
            +
                      }
         
     | 
| 
      
 409 
     | 
    
         
            +
                      query_params = params.clone
         
     | 
| 
      
 410 
     | 
    
         
            +
                      params.store("sessionId", sessionId)
         
     | 
| 
      
 411 
     | 
    
         
            +
                      puts query_params
         
     | 
| 
      
 412 
     | 
    
         
            +
                      signature = util.sign(@secret_key, params)
         
     | 
| 
      
 413 
     | 
    
         
            +
                      resource_url = "#{@version}/#{@resource}/id/#{sessionId}"
         
     | 
| 
      
 414 
     | 
    
         
            +
                      response = connection.delete(signature, resource_url, query_params)
         
     | 
| 
      
 415 
     | 
    
         
            +
                      responseObj.strResponse=(response)
         
     | 
| 
      
 416 
     | 
    
         
            +
                      responseObj.isResponseSuccess=(true)
         
     | 
| 
      
 417 
     | 
    
         
            +
                    rescue  App42Exception =>e
         
     | 
| 
      
 418 
     | 
    
         
            +
                      raise e
         
     | 
| 
      
 419 
     | 
    
         
            +
                    rescue  Exception => e
         
     | 
| 
      
 420 
     | 
    
         
            +
                      raise App42Exception.new(e)
         
     | 
| 
      
 421 
     | 
    
         
            +
                    end
         
     | 
| 
      
 422 
     | 
    
         
            +
                    return responseObj
         
     | 
| 
      
 423 
     | 
    
         
            +
                  end
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
                end
         
     | 
| 
      
 426 
     | 
    
         
            +
              end
         
     | 
| 
      
 427 
     | 
    
         
            +
            end
         
     |