module Session def get_session(key, options={}) options.merge!(basic_auth: @auth, headers: @headers) response = self.class.get(base_api_endpoint("Web/Session/#{key}"), options) JSON.parse(response.body) end def create_session(ip, options={}) parameters = { 'IpAddress': ip, 'Organization': 'Tessitura Web' } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(body: parameters) response = self.class.post(base_api_endpoint('Web/Session'), options) JSON.parse(response.body) end def transfer_session(session_key, new_session_key, options={}) parameters = { 'NewSessionKey': new_session_key, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(body: parameters) self.class.post(base_api_endpoint("Web/Session/#{session_key}/Transfer"), options) end def get_expiration(key, options={}) options.merge!(basic_auth: @auth, headers: @headers) response = self.class.get(base_api_endpoint("Web/Session/#{key}/Expiration"), options) JSON.parse(response.body) end def get_variables(key, options={}) options.merge!(basic_auth: @auth, headers: @headers) response = self.class.get(base_api_endpoint("Web/Session/#{key}/Variables"), options) JSON.parse(response.body) end def set_expiration(key, timeoffset, expiration, options={}) parameters = { 'Expiration': expiration, 'TimeOffset': timeoffset } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters) response = self.class.put(base_api_endpoint("Web/Session/#{key}/Expiration"), options) JSON.parse(response.body) end def load_existing_order(key, order_id, options={}) options.merge!(basic_auth: @auth, headers: @headers) self.class.post(base_api_endpoint("Web/Session/#{key}/LoadOrder/#{order_id}"), options) end def get_promotion(key, code, code_string, options={}) parameters = { 'PromoCode': code, 'PromoCodeString': code_string } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters) response = self.class.post(base_api_endpoint("Web/Session/#{key}/PromoCode"), options) JSON.parse(response.body) end def get_renewals(key, season_id, renewal, mode_of_sale, options={}) options.merge!(basic_auth: @auth, headers: @headers) response = self.class.get(base_api_endpoint("Web/Session/#{key}/Orders/Search?seasonId=#{season_id}&renewalsOnly=#{renewal}&modeOfSaleId=#{mode_of_sale}"), options) JSON.parse(response.body) end def send_credentials(key, email, login_type, template_id, options={}) parameters = { 'TemplateFormatId': template_id, 'LoginTypeId': login_type, 'EmailAddress': email } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters) self.class.post(base_api_endpoint("/Web/Session/#{key}/Login/SendCredentials"), options) end def update_login(key, user_name, old_password, new_password, email, new_email, options={}) parameters = { 'LoginName': user_name, 'NewLoginName': new_email, 'Password': old_password, 'NewPassword': new_password, 'EmailAddress': email, 'NewEmailAddress': new_email, 'LoginTypeId': 1, 'PromotionCode': 0, } options.merge!(basic_auth: @auth, headers: @headers) options.merge!(:body => parameters.to_json, :headers => {'Content-Type' => 'application/json'}) self.class.put(base_api_endpoint("Web/Session/#{key}/WebLogins"), options) end def get_shipping_methods(key, options={}) options.merge!(basic_auth: @auth, headers: @headers) response = self.class.get(base_api_endpoint("Web/Session/#{key}/DeliveryMethods"), options) JSON.parse(response.body) end end