megafon_sms 1.0.0
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 +11 -0
 - data/.rspec +3 -0
 - data/.rubocop.yml +74 -0
 - data/.travis.yml +7 -0
 - data/Gemfile +6 -0
 - data/Gemfile.lock +64 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +33 -0
 - data/Rakefile +8 -0
 - data/bin/console +15 -0
 - data/bin/setup +8 -0
 - data/lib/megafon_sms/client.rb +50 -0
 - data/lib/megafon_sms/error.rb +5 -0
 - data/lib/megafon_sms/version.rb +5 -0
 - data/lib/megafon_sms.rb +5 -0
 - data/megafon_sms.gemspec +35 -0
 - metadata +172 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 21149aad09cebdd5451cb03cbb189b9263c1cc04a20980e9bb3c27528588b6a3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: aa218738fd5bb7acdad40176dff87f3f5da175f39cfd30be3f067a1b30aace0c
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2c934428999b86d3990d913ed4810e2d9b57690940df1e0d28c0fee77ba28f813a18b007df6842df59732d7a2212385d1dc0d1a907af710cee03e26985ec6c31
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 7727b55e43d36b4916b9f8a63b3b264f47650e544f2e46059e73c9faa741375f801c73d780c394cae27703c62c998a2a4411ea437cfecb98689a6a814a3b92e7
         
     | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -0,0 +1,74 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            AllCops:
         
     | 
| 
      
 2 
     | 
    
         
            +
              TargetRubyVersion: 2.4
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Metrics/BlockLength:
         
     | 
| 
      
 5 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 6 
     | 
    
         
            +
                - "**/*_spec.rb"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Metrics/MethodLength:
         
     | 
| 
      
 9 
     | 
    
         
            +
              Max: 40
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Metrics/ModuleLength:
         
     | 
| 
      
 12 
     | 
    
         
            +
              Max: 200
         
     | 
| 
      
 13 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 14 
     | 
    
         
            +
                - "**/*_spec.rb"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Metrics/AbcSize:
         
     | 
| 
      
 17 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Metrics/CyclomaticComplexity:
         
     | 
| 
      
 20 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Metrics/PerceivedComplexity:
         
     | 
| 
      
 23 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            Layout/LineLength:
         
     | 
| 
      
 26 
     | 
    
         
            +
              Max: 120
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            Layout/ParameterAlignment:
         
     | 
| 
      
 29 
     | 
    
         
            +
              EnforcedStyle: with_fixed_indentation
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            Layout/CaseIndentation:
         
     | 
| 
      
 32 
     | 
    
         
            +
              EnforcedStyle: case
         
     | 
| 
      
 33 
     | 
    
         
            +
              SupportedStyles:
         
     | 
| 
      
 34 
     | 
    
         
            +
                - case
         
     | 
| 
      
 35 
     | 
    
         
            +
                - end
         
     | 
| 
      
 36 
     | 
    
         
            +
              IndentOneStep: true
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            Layout/EndAlignment:
         
     | 
| 
      
 39 
     | 
    
         
            +
              EnforcedStyleAlignWith: variable
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            Style/PercentLiteralDelimiters:
         
     | 
| 
      
 42 
     | 
    
         
            +
              PreferredDelimiters:
         
     | 
| 
      
 43 
     | 
    
         
            +
                '%w': "[]"
         
     | 
| 
      
 44 
     | 
    
         
            +
                '%W': "[]"
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            Style/StringLiterals:
         
     | 
| 
      
 47 
     | 
    
         
            +
              EnforcedStyle: double_quotes
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Style/StringLiteralsInInterpolation:
         
     | 
| 
      
 50 
     | 
    
         
            +
              EnforcedStyle: double_quotes
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            Style/StructInheritance:
         
     | 
| 
      
 53 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            Style/AndOr:
         
     | 
| 
      
 56 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            Style/Not:
         
     | 
| 
      
 59 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            Style/DoubleNegation:
         
     | 
| 
      
 62 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            Style/HashEachMethods:
         
     | 
| 
      
 65 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            Style/HashTransformKeys:
         
     | 
| 
      
 68 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            Style/HashTransformValues:
         
     | 
| 
      
 71 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            Documentation:
         
     | 
| 
      
 74 
     | 
    
         
            +
              Enabled: false
         
     | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            PATH
         
     | 
| 
      
 2 
     | 
    
         
            +
              remote: .
         
     | 
| 
      
 3 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 4 
     | 
    
         
            +
                megafon_sms (1.0.0)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            GEM
         
     | 
| 
      
 7 
     | 
    
         
            +
              remote: https://rubygems.org/
         
     | 
| 
      
 8 
     | 
    
         
            +
              specs:
         
     | 
| 
      
 9 
     | 
    
         
            +
                ast (2.4.0)
         
     | 
| 
      
 10 
     | 
    
         
            +
                diff-lcs (1.3)
         
     | 
| 
      
 11 
     | 
    
         
            +
                faraday (1.0.1)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  multipart-post (>= 1.2, < 3)
         
     | 
| 
      
 13 
     | 
    
         
            +
                faraday_middleware (1.0.0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  faraday (~> 1.0)
         
     | 
| 
      
 15 
     | 
    
         
            +
                jaro_winkler (1.5.4)
         
     | 
| 
      
 16 
     | 
    
         
            +
                json (2.3.0)
         
     | 
| 
      
 17 
     | 
    
         
            +
                multipart-post (2.1.1)
         
     | 
| 
      
 18 
     | 
    
         
            +
                parallel (1.19.1)
         
     | 
| 
      
 19 
     | 
    
         
            +
                parser (2.7.0.5)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  ast (~> 2.4.0)
         
     | 
| 
      
 21 
     | 
    
         
            +
                rainbow (3.0.0)
         
     | 
| 
      
 22 
     | 
    
         
            +
                rake (10.5.0)
         
     | 
| 
      
 23 
     | 
    
         
            +
                rexml (3.2.4)
         
     | 
| 
      
 24 
     | 
    
         
            +
                rspec (3.9.0)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  rspec-core (~> 3.9.0)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  rspec-expectations (~> 3.9.0)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  rspec-mocks (~> 3.9.0)
         
     | 
| 
      
 28 
     | 
    
         
            +
                rspec-core (3.9.1)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  rspec-support (~> 3.9.1)
         
     | 
| 
      
 30 
     | 
    
         
            +
                rspec-expectations (3.9.1)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  rspec-support (~> 3.9.0)
         
     | 
| 
      
 33 
     | 
    
         
            +
                rspec-mocks (3.9.1)
         
     | 
| 
      
 34 
     | 
    
         
            +
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  rspec-support (~> 3.9.0)
         
     | 
| 
      
 36 
     | 
    
         
            +
                rspec-support (3.9.2)
         
     | 
| 
      
 37 
     | 
    
         
            +
                rubocop (0.80.1)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  jaro_winkler (~> 1.5.1)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  parallel (~> 1.10)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  parser (>= 2.7.0.1)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  rainbow (>= 2.2.2, < 4.0)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  rexml
         
     | 
| 
      
 43 
     | 
    
         
            +
                  ruby-progressbar (~> 1.7)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  unicode-display_width (>= 1.4.0, < 1.7)
         
     | 
| 
      
 45 
     | 
    
         
            +
                ruby-progressbar (1.10.1)
         
     | 
| 
      
 46 
     | 
    
         
            +
                unicode-display_width (1.6.1)
         
     | 
| 
      
 47 
     | 
    
         
            +
                vcr (5.1.0)
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            PLATFORMS
         
     | 
| 
      
 50 
     | 
    
         
            +
              ruby
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            DEPENDENCIES
         
     | 
| 
      
 53 
     | 
    
         
            +
              bundler (~> 2.0)
         
     | 
| 
      
 54 
     | 
    
         
            +
              faraday (~> 1.0)
         
     | 
| 
      
 55 
     | 
    
         
            +
              faraday_middleware (~> 1.0)
         
     | 
| 
      
 56 
     | 
    
         
            +
              json (~> 2.3)
         
     | 
| 
      
 57 
     | 
    
         
            +
              megafon_sms!
         
     | 
| 
      
 58 
     | 
    
         
            +
              rake (~> 10.0)
         
     | 
| 
      
 59 
     | 
    
         
            +
              rspec (~> 3.0)
         
     | 
| 
      
 60 
     | 
    
         
            +
              rubocop (= 0.80.1)
         
     | 
| 
      
 61 
     | 
    
         
            +
              vcr (= 5.1)
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            BUNDLED WITH
         
     | 
| 
      
 64 
     | 
    
         
            +
               2.0.2
         
     | 
    
        data/LICENSE.txt
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            The MIT License (MIT)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Copyright (c) 2020 heckfy
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
      
 6 
     | 
    
         
            +
            of this software and associated documentation files (the "Software"), to deal
         
     | 
| 
      
 7 
     | 
    
         
            +
            in the Software without restriction, including without limitation the rights
         
     | 
| 
      
 8 
     | 
    
         
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         
     | 
| 
      
 9 
     | 
    
         
            +
            copies of the Software, and to permit persons to whom the Software is
         
     | 
| 
      
 10 
     | 
    
         
            +
            furnished to do so, subject to the following conditions:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in
         
     | 
| 
      
 13 
     | 
    
         
            +
            all copies or substantial portions of the Software.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 16 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         
     | 
| 
      
 17 
     | 
    
         
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         
     | 
| 
      
 18 
     | 
    
         
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         
     | 
| 
      
 19 
     | 
    
         
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         
     | 
| 
      
 20 
     | 
    
         
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         
     | 
| 
      
 21 
     | 
    
         
            +
            THE SOFTWARE.
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # MegafonSms
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            MegafonSms - это библиотека для отправки SMS через сервис Мегафона.
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## Установка
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Выполняем в терминале:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                $ gem install megafon_sms
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            и подгружаем:
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 14 
     | 
    
         
            +
            require "megafon_sms"
         
     | 
| 
      
 15 
     | 
    
         
            +
            ```
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ## Использование
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 20 
     | 
    
         
            +
            client = MegafonSms::Client.new "login", "password"
         
     | 
| 
      
 21 
     | 
    
         
            +
            client.adapter = :excon # По умочанию Net::HTTP
         
     | 
| 
      
 22 
     | 
    
         
            +
            client.send from: "Site.ru", to: "9776666644", message: "Сообщение"
         
     | 
| 
      
 23 
     | 
    
         
            +
            p client.response if client.failure?
         
     | 
| 
      
 24 
     | 
    
         
            +
            ```
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/heckfy/megafon_sms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
         
     | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "megafon_sms"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # You can add fixtures and/or initialization code here to make experimenting
         
     | 
| 
      
 8 
     | 
    
         
            +
            # with your gem easier. You can also use a different console, if you like.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         
     | 
| 
      
 11 
     | 
    
         
            +
            # require "pry"
         
     | 
| 
      
 12 
     | 
    
         
            +
            # Pry.start
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            require "irb"
         
     | 
| 
      
 15 
     | 
    
         
            +
            IRB.start(__FILE__)
         
     | 
    
        data/bin/setup
    ADDED
    
    
| 
         @@ -0,0 +1,50 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "base64"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "faraday"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "faraday_middleware"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "json"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module MegafonSms
         
     | 
| 
      
 9 
     | 
    
         
            +
              class Client
         
     | 
| 
      
 10 
     | 
    
         
            +
                URL = "https://a2p-api.megalabs.ru/sms/v1/sms"
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                attr_accessor :adapter
         
     | 
| 
      
 13 
     | 
    
         
            +
                attr_reader :connection, :response, :login, :password
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def initialize(login, password)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @adapter = Faraday.default_adapter
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @login = login
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @password = password
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  @connection = Faraday.new do |conn|
         
     | 
| 
      
 21 
     | 
    
         
            +
                    conn.response :json, content_type: /\bjson$/
         
     | 
| 
      
 22 
     | 
    
         
            +
                    conn.adapter adapter
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def send(from:, to:, message:, callback_url: nil, msg_id: nil)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  body = { from: from, to: to.to_i, message: message.to_s, callback_url: callback_url, msg_id: msg_id }.to_json
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @response = connection.post(URL, body, headers)
         
     | 
| 
      
 29 
     | 
    
         
            +
                rescue StandardError => e
         
     | 
| 
      
 30 
     | 
    
         
            +
                  raise MegafonSms::Error, e
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def success?
         
     | 
| 
      
 34 
     | 
    
         
            +
                  response && response.status == 200 && response.body["result"]["status"]["code"] == 0
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def failure?
         
     | 
| 
      
 38 
     | 
    
         
            +
                  !success?
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                private
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                def headers
         
     | 
| 
      
 44 
     | 
    
         
            +
                  {
         
     | 
| 
      
 45 
     | 
    
         
            +
                    "Content-Type" => "application/json",
         
     | 
| 
      
 46 
     | 
    
         
            +
                    "Authorization" => "Basic #{Base64.encode64([login, password].join(":"))}"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  }
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/megafon_sms.rb
    ADDED
    
    
    
        data/megafon_sms.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            lib = File.expand_path("lib", __dir__)
         
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "megafon_sms/version"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Gem::Specification.new do |spec|
         
     | 
| 
      
 8 
     | 
    
         
            +
              spec.name          = "megafon_sms"
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.version       = MegafonSms::VERSION
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.authors       = ["heckfy"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.email         = ["heckfyoz@gmail.com"]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              spec.summary       = "The library for sending sms through Megafon REST API,"
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.description   = "The library for sending sms through Megafon REST API,"
         
     | 
| 
      
 15 
     | 
    
         
            +
              spec.homepage      = "https://github.com/heckfy/megafon_sms"
         
     | 
| 
      
 16 
     | 
    
         
            +
              spec.license       = "MIT"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # Specify which files should be added to the gem when it is released.
         
     | 
| 
      
 19 
     | 
    
         
            +
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         
     | 
| 
      
 20 
     | 
    
         
            +
              spec.files         = Dir.chdir(File.expand_path(__dir__)) do
         
     | 
| 
      
 21 
     | 
    
         
            +
                `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
              spec.bindir        = "exe"
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.require_paths = ["lib"]
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              spec.add_development_dependency "bundler", "~> 2.0"
         
     | 
| 
      
 28 
     | 
    
         
            +
              spec.add_development_dependency "faraday", "~> 1.0"
         
     | 
| 
      
 29 
     | 
    
         
            +
              spec.add_development_dependency "faraday_middleware", "~> 1.0"
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_development_dependency "json", "~> 2.3"
         
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
      
 32 
     | 
    
         
            +
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
      
 33 
     | 
    
         
            +
              spec.add_development_dependency "rubocop", "0.80.1"
         
     | 
| 
      
 34 
     | 
    
         
            +
              spec.add_development_dependency "vcr", "5.1"
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,172 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: megafon_sms
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - heckfy
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-04-01 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: faraday
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: faraday_middleware
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '2.3'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '2.3'
         
     | 
| 
      
 69 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 72 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 73 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 75 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 76 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 77 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '10.0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: rspec
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: rubocop
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - '='
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: 0.80.1
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - '='
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: 0.80.1
         
     | 
| 
      
 111 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: vcr
         
     | 
| 
      
 113 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - '='
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                    version: '5.1'
         
     | 
| 
      
 118 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 119 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 120 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
                - - '='
         
     | 
| 
      
 123 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                    version: '5.1'
         
     | 
| 
      
 125 
     | 
    
         
            +
            description: The library for sending sms through Megafon REST API,
         
     | 
| 
      
 126 
     | 
    
         
            +
            email:
         
     | 
| 
      
 127 
     | 
    
         
            +
            - heckfyoz@gmail.com
         
     | 
| 
      
 128 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 129 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 130 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 131 
     | 
    
         
            +
            files:
         
     | 
| 
      
 132 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 133 
     | 
    
         
            +
            - ".rspec"
         
     | 
| 
      
 134 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
      
 135 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 136 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 137 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 138 
     | 
    
         
            +
            - LICENSE.txt
         
     | 
| 
      
 139 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 140 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 141 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 142 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
      
 143 
     | 
    
         
            +
            - lib/megafon_sms.rb
         
     | 
| 
      
 144 
     | 
    
         
            +
            - lib/megafon_sms/client.rb
         
     | 
| 
      
 145 
     | 
    
         
            +
            - lib/megafon_sms/error.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - lib/megafon_sms/version.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - megafon_sms.gemspec
         
     | 
| 
      
 148 
     | 
    
         
            +
            homepage: https://github.com/heckfy/megafon_sms
         
     | 
| 
      
 149 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 150 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 151 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 152 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 153 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 154 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 155 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 156 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 157 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 158 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 159 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 160 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 161 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 162 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 163 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 164 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 165 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 166 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 167 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 168 
     | 
    
         
            +
            rubygems_version: 2.7.6.2
         
     | 
| 
      
 169 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 170 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 171 
     | 
    
         
            +
            summary: The library for sending sms through Megafon REST API,
         
     | 
| 
      
 172 
     | 
    
         
            +
            test_files: []
         
     |