rtr_http_gateway 1.0.0 → 1.0.1
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 +4 -4
 - data/lib/rtr_http_gateway.rb +18 -3
 - metadata +48 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c7f479c6f6fe89084408a365d7f293c25168a9f8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4df2e4f71a3d55c1c6713e5e5829e4ec154ddff6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d0a5dafc74f3c20b86546f9c04ba85df7c2913352e3d3fa9e5d1a92ba9b543e4309f8585c018150417e7944775db9d479c2f9b15f8fa19c00e5dc3b95de36c64
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fcc6b1303dd532a3a6b96ddd540569b053d58dfa7c624a635f123eb6581eac44fbc934e40af108deca3eedeaf2bf725c245d47ff50f25cc94661d136f7fd7f6c
         
     | 
    
        data/lib/rtr_http_gateway.rb
    CHANGED
    
    | 
         @@ -6,6 +6,7 @@ module RtrHttpGateway 
     | 
|
| 
       6 
6 
     | 
    
         
             
              class HttpGatewayException < StandardError
         
     | 
| 
       7 
7 
     | 
    
         
             
              end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
      
 9 
     | 
    
         
            +
              # Represents The Delivery receipt status and reason code
         
     | 
| 
       9 
10 
     | 
    
         
             
              class DlrQueryResponse
         
     | 
| 
       10 
11 
     | 
    
         
             
                def initialize(status, reason_code, msg_id)
         
     | 
| 
       11 
12 
     | 
    
         
             
                  @status = status
         
     | 
| 
         @@ -14,7 +15,7 @@ module RtrHttpGateway 
     | 
|
| 
       14 
15 
     | 
    
         
             
                end
         
     | 
| 
       15 
16 
     | 
    
         
             
                attr_reader :status, :reason_code, :msg_id
         
     | 
| 
       16 
17 
     | 
    
         
             
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       18 
19 
     | 
    
         
             
              class HttpGatewayApi
         
     | 
| 
       19 
20 
     | 
    
         
             
                def initialize(username, password, service_key, url='https://connect.runthered.com:14004/public_api/sms/gateway/', dlr_url='https://connect.runthered.com:14004/public_api/sms/dlr/')
         
     | 
| 
       20 
21 
     | 
    
         
             
                  @url = url
         
     | 
| 
         @@ -27,6 +28,7 @@ module RtrHttpGateway 
     | 
|
| 
       27 
28 
     | 
    
         
             
                def do_post_request(url_string, values)
         
     | 
| 
       28 
29 
     | 
    
         
             
                  uri = URI.parse(url_string)
         
     | 
| 
       29 
30 
     | 
    
         
             
                  http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  http.use_ssl = true if uri.scheme == 'https'
         
     | 
| 
       30 
32 
     | 
    
         
             
                  request = Net::HTTP::Post.new(uri.request_uri)
         
     | 
| 
       31 
33 
     | 
    
         
             
                  request.set_form_data(values)
         
     | 
| 
       32 
34 
     | 
    
         
             
                  request.basic_auth @username, @password
         
     | 
| 
         @@ -37,12 +39,21 @@ module RtrHttpGateway 
     | 
|
| 
       37 
39 
     | 
    
         
             
                def do_get_request(url_string)
         
     | 
| 
       38 
40 
     | 
    
         
             
                  uri = URI.parse(url_string)
         
     | 
| 
       39 
41 
     | 
    
         
             
                  http = Net::HTTP.new(uri.host, uri.port)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  http.use_ssl = true if uri.scheme == 'https'
         
     | 
| 
       40 
43 
     | 
    
         
             
                  request = Net::HTTP::Get.new(uri.request_uri)
         
     | 
| 
       41 
44 
     | 
    
         
             
                  request.basic_auth @username, @password
         
     | 
| 
       42 
45 
     | 
    
         
             
                  response = http.request(request)
         
     | 
| 
       43 
46 
     | 
    
         
             
                  return response
         
     | 
| 
       44 
47 
     | 
    
         
             
                end
         
     | 
| 
       45 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
                # Send a message to Run The Red
         
     | 
| 
      
 50 
     | 
    
         
            +
                # @param message [String] the message to send
         
     | 
| 
      
 51 
     | 
    
         
            +
                # @param to [String] the mobile number to send to
         
     | 
| 
      
 52 
     | 
    
         
            +
                # @param from_number [String] the shortcode the message will come from
         
     | 
| 
      
 53 
     | 
    
         
            +
                # @param billing_code [String] the billing code for the message, if required
         
     | 
| 
      
 54 
     | 
    
         
            +
                # @param partner_reference [String] a client supplied reference string, if required
         
     | 
| 
      
 55 
     | 
    
         
            +
                # @raise [HttpGatewayException] if a non 200 response is returned by Run The Red
         
     | 
| 
      
 56 
     | 
    
         
            +
                # @return [String] the message id of the message created in Run The Red's system
         
     | 
| 
       46 
57 
     | 
    
         
             
                def push_message(message, to, from_number=nil, billing_code=nil, partner_reference=nil)
         
     | 
| 
       47 
58 
     | 
    
         
             
                  values = {'message'=>message, 'to'=>to}
         
     | 
| 
       48 
59 
     | 
    
         
             
                  unless from_number.nil?
         
     | 
| 
         @@ -58,9 +69,13 @@ module RtrHttpGateway 
     | 
|
| 
       58 
69 
     | 
    
         
             
                  if response.code != '200'
         
     | 
| 
       59 
70 
     | 
    
         
             
                    raise HttpGatewayException, response.code
         
     | 
| 
       60 
71 
     | 
    
         
             
                  end
         
     | 
| 
       61 
     | 
    
         
            -
                  return response
         
     | 
| 
      
 72 
     | 
    
         
            +
                  return response.body
         
     | 
| 
       62 
73 
     | 
    
         
             
                end
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                # Query a delivery receipt using the message id supplied by Run The Red
         
     | 
| 
      
 76 
     | 
    
         
            +
                # @param msg_id [String] the message id of the message to check the delivery status of
         
     | 
| 
      
 77 
     | 
    
         
            +
                # @raise [HttpGatewayException] if a non 200 response is returned by Ru The Red
         
     | 
| 
      
 78 
     | 
    
         
            +
                # @return [DlrQueryResponse] an object with the status, reason_code and msg_id as attributes		
         
     | 
| 
       64 
79 
     | 
    
         
             
                def query_dlr(msg_id)
         
     | 
| 
       65 
80 
     | 
    
         
             
                  values = {'id' => msg_id}
         
     | 
| 
       66 
81 
     | 
    
         
             
                  params = URI.encode_www_form(values)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rtr_http_gateway
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Finn Colman
         
     | 
| 
         @@ -9,9 +9,50 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         
             
            date: 2015-09-14 00:00:00.000000000 Z
         
     | 
| 
       12 
     | 
    
         
            -
            dependencies: 
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
               
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: webmock
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            description: Wrapper library for calling Run The Red's HTTP gateway from ruby.
         
     | 
| 
       15 
56 
     | 
    
         
             
            email: finn.colman@runthered.com
         
     | 
| 
       16 
57 
     | 
    
         
             
            executables: []
         
     | 
| 
       17 
58 
     | 
    
         
             
            extensions: []
         
     | 
| 
         @@ -38,8 +79,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       38 
79 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       39 
80 
     | 
    
         
             
            requirements: []
         
     | 
| 
       40 
81 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       41 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 82 
     | 
    
         
            +
            rubygems_version: 2.4.8
         
     | 
| 
       42 
83 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       43 
84 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       44 
     | 
    
         
            -
            summary:  
     | 
| 
      
 85 
     | 
    
         
            +
            summary: Run The Red HTTP Gateway library
         
     | 
| 
       45 
86 
     | 
    
         
             
            test_files: []
         
     | 
| 
      
 87 
     | 
    
         
            +
            has_rdoc: 
         
     |