Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Alfa
- module Telia
- class Client
- attr_reader :params
- ENDPOINT = 'https://teenused.elion.ee:443/external/services/index.php'
- WSDL = 'https://teenused.elion.ee/external/services/index.php?wsdl'
- USER = '3726557071@elion.ee'
- PASSWORD = 'ave4weYH'
- def initialize(params)
- @params = params
- end
- def get_call_history(number)
- send_request(:get_call_history, call_history_message(number))
- end
- def call_number(number_from, number_to)
- send_request(:click_to_call, click_to_call_message(number_from, number_to))
- end
- private
- def client
- @client ||= Savon.client(
- wsdl: WSDL,
- endpoint: ENDPOINT,
- wsse_auth: [USER, PASSWORD],
- convert_request_keys_to: :camelcase,
- log_level: :debug,
- log: true,
- pretty_print_xml: true,
- )
- end
- def send_request(action, message)
- client.call(action, message: message.deep_symbolize_keys)
- rescue Savon::InvalidResponseError
- raise('Invalid reponse from Telia')
- end
- def call_history_message
- { 'getCallHistory' => params }
- end
- def click_to_call_message
- { 'click_to_call' => params }
- end
- end
- end
- end
- Alfa::Telia::Client.new('Anumber' => number_from, 'Bnumber' => number_to).call_number
- Alfa::Telia::Client.new('Anumber' => '12356').get_call_history
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement