sms_traffic_sdk 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97b598c2448cc5371fb1d2dd91d0f5706473ea3657e5494e4e72edb53a304792
4
- data.tar.gz: 4f42caff68f07f17e841119111b013dd40be2cda9b321bb8e7bdafa4509ddb2e
3
+ metadata.gz: a24fc568f771f8a36b3b9c6cf8593b653441ca3f98bba4ab214a26f4cdbee01b
4
+ data.tar.gz: 5a1bf2789cba41f9334199342efed9d0d8e3c0ddaf6aba581fe99797ae10ff82
5
5
  SHA512:
6
- metadata.gz: 2b09f25a918672f487011f79861441f96b650625f1fc9cf0db213a9204b8cfab9f78b1d883b3ed76da5ba0d6b47d6bd1d52710c0cb902e386cffc0f625f76c13
7
- data.tar.gz: fe2cfb46546cf8438b325e2a676e28792d2ff585a13ac75304af2a3079a2401f72acbb7c00c7af2f5fe3a2748a799d622f204dec1442b025215f96ccfd38239b
6
+ metadata.gz: 0546d6134d67834a19e5ec0fcc97f8ecc6e5db0de31bb2cba5c13780097554abc866ce1702974bf51ef958204b46603f3ff6b2bf97e595f8c3388b946e9338de
7
+ data.tar.gz: 2aca58a629bc318d0da343486c2ed2072f2048b774dee6507aa23b8e5209adaaf80312fd76a4ade0d075234bf08db940aa04ba54ccfb865943ce4ba063997bef
@@ -7,10 +7,6 @@ on:
7
7
  branches: [ main ]
8
8
  release:
9
9
  types: [created]
10
- on:
11
- push:
12
- tags:
13
- - 'v*'
14
10
 
15
11
  jobs:
16
12
  build:
@@ -51,6 +47,7 @@ jobs:
51
47
  publish:
52
48
  needs: build
53
49
  runs-on: ubuntu-latest
50
+ if: startsWith(github.ref, 'refs/tags/v')
54
51
  steps:
55
52
  - uses: actions/checkout@v2
56
53
 
data/README.md CHANGED
@@ -1,10 +1,21 @@
1
1
  # SmsTraffic
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/sms_traffic.svg)](https://badge.fury.io/rb/sms_traffic)
3
+ [![Gem Version](https://badge.fury.io/rb/sms_traffic_sdk.svg)](https://badge.fury.io/rb/sms_traffic_sdk)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/bb4795be5024dd81d927/maintainability)](https://codeclimate.com/github/golifox/sms_traffic/maintainability)
5
5
  [![Coverage](https://codecov.io/github/golifox/sms_traffic/graph/badge.svg?token=74C0YBJP3F)](https://codecov.io/github/golifox/sms_traffic)
6
6
  [![CI](https://github.com/golifox/sms_traffic/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/golifox/sms_traffic/actions/workflows/ci.yml)
7
7
 
8
+ Ruby Gem as a software development kit (SDK) that facilitates interaction with the SMS Traffic HTTP API (smstraffic.ru/api).
9
+ This gem provides a convenient wrapper to integrate SMS Traffic services within Ruby applications, allowing for easy
10
+ sending of SMS messages and checking delivery statuses.
11
+
12
+ ## Features
13
+
14
+ - Send SMS messages to single or multiple recipients.
15
+ - Check the delivery status of sent messages.
16
+ - **TODO:** Support for various message formats and encodings.
17
+
18
+
8
19
  ## Installation
9
20
 
10
21
  Add this line to your application's Gemfile:
@@ -23,7 +34,6 @@ Or install it yourself as:
23
34
 
24
35
  ## Usage
25
36
 
26
-
27
37
  Define settings:
28
38
 
29
39
  ```ruby
@@ -81,13 +91,26 @@ reply.hash
81
91
 
82
92
  ```
83
93
 
84
- ## Development
94
+ # Contributing
95
+
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/golifox/sms_traffic_sdk.
85
97
 
86
98
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
87
99
 
88
- To install this gem onto your local machine, run `bundle exec rake install`.
100
+ To install this gem onto your local machine, run `bundle exec rake install`.
89
101
 
90
102
  ## License
91
103
 
92
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
104
+ The gem is available as open-source under the terms of the [MIT License](LICENSE).
105
+
106
+ ## Contact
107
+
108
+ If you have any questions or feedback regarding SMS Traffic SDK, please feel free to contact us via GitHub issues or directly by email at i@golifox.ru.
109
+
110
+ ## Acknowledgments
111
+
112
+ - Thanks to the SMS Traffic team for providing the API that this gem is based upon.
113
+ - Anyone who contributes to this project is greatly appreciated.
114
+
115
+ For more information please visit [SMS Traffic API docs](http://smstraffic.ru/api).
93
116
 
@@ -5,6 +5,8 @@ module SmsTraffic
5
5
 
6
6
  def ok?
7
7
  fetch_value(hash, :result) == OK_REPLY
8
+ rescue NoMethodError
9
+ false
8
10
  end
9
11
 
10
12
  def error?
@@ -29,7 +31,7 @@ module SmsTraffic
29
31
 
30
32
  def sms_id(phone = nil)
31
33
  message_info = fetch_value(message_infos, :message_info)
32
- return fetch_value(message_info, :sms_id) if message_info.is_a?(Hash)
34
+ return fetch_value(message_info, :sms_id) if message_info.is_a?(Hash) || message_info.nil?
33
35
 
34
36
  raise ArgumentError, 'phone is required' unless phone
35
37
 
@@ -4,7 +4,7 @@ module SmsTraffic
4
4
  attr_reader :xml, :hash
5
5
 
6
6
  def initialize(xml, xml_parser: SmsTraffic.configuration.xml_parser)
7
- @xml = xml.gsub!(/\s+/, ' ')
7
+ @xml = xml.gsub!(/\s+/, ' ')
8
8
  @hash = fetch_value(xml_parser.parse(xml), :reply)
9
9
  end
10
10
 
@@ -12,6 +12,8 @@ module SmsTraffic
12
12
 
13
13
  def fetch_value(hash, key)
14
14
  hash.fetch(key.to_s, nil) || hash.fetch(key.to_sym, nil)
15
+ rescue NoMethodError
16
+ nil
15
17
  end
16
18
  end
17
19
  end
@@ -5,12 +5,13 @@ module SmsTraffic
5
5
  class Configuration
6
6
  include Singleton
7
7
 
8
- attr_accessor :login, :password, :host, :originator, :debug, :logger, :xml_parser
8
+ attr_accessor :login, :password, :host, :originator, :debug, :logger, :xml_parser, :validate_phone
9
9
 
10
10
  def initialize
11
- self.debug = default_configuration[:debug]
12
- self.logger = default_configuration[:logger]
13
- self.xml_parser = default_configuration[:xml_parser]
11
+ self.debug = default_configuration[:debug]
12
+ self.logger = default_configuration[:logger]
13
+ self.xml_parser = default_configuration[:xml_parser]
14
+ self.validate_phone = default_configuration[:validate_phone]
14
15
  super
15
16
  end
16
17
 
@@ -46,13 +47,14 @@ module SmsTraffic
46
47
 
47
48
  def default_configuration
48
49
  {
49
- login: nil,
50
- password: nil,
51
- host: nil,
52
- originator: nil,
53
- debug: false,
54
- logger: $stdout,
55
- xml_parser: default_xml_parser
50
+ login: nil,
51
+ password: nil,
52
+ host: nil,
53
+ originator: nil,
54
+ debug: false,
55
+ logger: $stdout,
56
+ xml_parser: default_xml_parser,
57
+ validate_phone: true
56
58
  }
57
59
  end
58
60
 
@@ -4,11 +4,11 @@ module SmsTraffic
4
4
  attr_reader :id, :status, :errors
5
5
 
6
6
  def initialize(phone, message, originator: nil)
7
- @phone = phone
8
- @message = message
7
+ @phone = phone
8
+ @message = message
9
9
  @originator = originator || SmsTraffic.configuration.originator
10
- @status = 'not-sent'
11
- @errors = []
10
+ @status = 'not-sent'
11
+ @errors = []
12
12
  validate!
13
13
  end
14
14
 
@@ -26,10 +26,10 @@ module SmsTraffic
26
26
 
27
27
  if reply.ok?
28
28
  @status = 'sent'
29
- @id = reply.sms_id
29
+ @id = reply.sms_id
30
30
  true
31
31
  else
32
- @errors << reply.error_description
32
+ @errors << (reply.error_description || 'Sms has been not enqueued')
33
33
  false
34
34
  end
35
35
  end
@@ -45,10 +45,10 @@ module SmsTraffic
45
45
 
46
46
  private
47
47
 
48
- def validate!
48
+ def validate! # rubocop:disable Metrics/ AbcSize
49
49
  raise ArgumentError, "Phone should be assigned to #{self.class}." if phone.nil?
50
50
 
51
- unless phone.to_s =~ /^[0-9]{11}$/
51
+ if SmsTraffic.configuration.validate_phone && phone.to_s !~ /^[0-9]{11,}$/
52
52
  raise ArgumentError, 'Phone number should contain only numbers. Minimum length is 11.'
53
53
  end
54
54
 
@@ -1,3 +1,3 @@
1
1
  module SmsTraffic
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.3'.freeze
3
3
  end
@@ -10,7 +10,9 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ['i@golifox.ru']
11
11
 
12
12
  spec.summary = 'Send sms via SmsTraffic service.'
13
- spec.description = 'Send sms via SmsTraffic service.'
13
+ spec.description = 'Ruby Gem as a SDK for interacting with the SMS Traffic HTTP API (smstraffic.ru/api).
14
+ This gem provides a convenient way to integrate SMS Traffic services into Ruby applications,
15
+ enabling tasks such as sending SMS messages, checking delivery status, and others.'
14
16
  spec.homepage = 'https://github.com/golifox/sms_traffic'
15
17
  spec.license = 'MIT'
16
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sms_traffic_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rybolovlev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -52,7 +52,10 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.5'
55
- description: Send sms via SmsTraffic service.
55
+ description: |-
56
+ Ruby Gem as a SDK for interacting with the SMS Traffic HTTP API (smstraffic.ru/api).
57
+ This gem provides a convenient way to integrate SMS Traffic services into Ruby applications,
58
+ enabling tasks such as sending SMS messages, checking delivery status, and others.
56
59
  email:
57
60
  - i@golifox.ru
58
61
  executables:
@@ -89,7 +92,7 @@ licenses:
89
92
  - MIT
90
93
  metadata:
91
94
  rubygems_mfa_required: 'true'
92
- post_install_message:
95
+ post_install_message:
93
96
  rdoc_options: []
94
97
  require_paths:
95
98
  - lib
@@ -105,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
108
  version: '0'
106
109
  requirements: []
107
110
  rubygems_version: 3.5.11
108
- signing_key:
111
+ signing_key:
109
112
  specification_version: 4
110
113
  summary: Send sms via SmsTraffic service.
111
114
  test_files: []