mprofi_api_client 0.1.0 → 0.1.2
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 +5 -5
- data/LICENSE +7 -7
- data/README.md +14 -8
- data/lib/mprofi_api_client/connector.rb +14 -1
- data/lib/mprofi_api_client.rb +1 -1
- data/mprofi_api_client.gemspec +4 -4
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e672e6efb39e725b2e70c5ca5fb305da4791f6bba01f7f5a342b4b99d598c4f5
|
4
|
+
data.tar.gz: f990673eac1bf7e0c2f3346303d1383374d479ada6041c04b9d2806bc5846731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d01c66ac892de2bcf5733d1a698f1f073a5b3493e9fef42a957aa5d8543f423e430731b263c485d3c0add12dbbff3ff8761f41f9d3f2fe7d9662f29694272bb9
|
7
|
+
data.tar.gz: 36148abd51b617bef3aab90198eaf6e247b51e6a09c7108752b7d7566023cd6b5c544fd322865804a4ad7b63fc1de7f33edd4f927469d83d3f99ad9204d60f0c
|
data/LICENSE
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
Copyright (c) 2015,
|
1
|
+
Copyright (c) 2015, COMVERGA Sp. z o. o.
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
5
|
|
6
6
|
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
7
|
|
8
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
|
9
9
|
documentation and/or other materials provided with the distribution.
|
10
10
|
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
12
|
-
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
13
|
-
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
14
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
15
|
-
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
12
|
+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
13
|
+
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
14
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
15
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
16
16
|
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](http://badge.fury.io/rb/mprofi_api_client)
|
1
2
|
|
2
3
|
# Mprofi API connector
|
3
4
|
|
@@ -13,17 +14,17 @@ gem 'mprofi_api_client'
|
|
13
14
|
|
14
15
|
# or
|
15
16
|
|
16
|
-
gem 'mprofi_api_client', :git => 'https://github.com/
|
17
|
+
gem 'mprofi_api_client', :git => 'https://github.com/comverga/mprofi_api_client_ruby.git'
|
17
18
|
|
18
19
|
```
|
19
20
|
|
20
21
|
### From github.com
|
21
22
|
|
22
23
|
```bash
|
23
|
-
git clone https://github.com/
|
24
|
+
git clone https://github.com/comverga/mprofi_api_client_ruby.git
|
24
25
|
cd mprofi_api_client_ruby
|
25
26
|
rake build
|
26
|
-
gem install mprofi_api_client-0.1.
|
27
|
+
gem install mprofi_api_client-0.1.1.gem
|
27
28
|
```
|
28
29
|
|
29
30
|
# Usage
|
@@ -37,14 +38,19 @@ connector = MprofiApiClient::Connector.new(API_TOKEN)
|
|
37
38
|
# or
|
38
39
|
# connector = MprofiApiClient::Connector.new(API_TOKEN, 'http://your_proxy_host_address:8080/')
|
39
40
|
begin
|
41
|
+
# you can change read_timeout if the default of 60 seconds is not enough
|
42
|
+
# connector.read_timeout = 120
|
40
43
|
connector.add_message('501002003', 'Test message 1', 'your-msg-id-001')
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
+
# message with Polish diacritics
|
45
|
+
connector.add_message('601002003', 'Test message ąćęłńóśźż', 'your-msg-id-002', encoding: 'utf-8')
|
46
|
+
# scheduled message
|
47
|
+
connector.add_message('701002003', 'Test message 3', 'your-msg-id-003', date: '2022-08-30T12:00:00+02:00')
|
48
|
+
result = connector.send
|
49
|
+
# => [{"id"=>58},{"id"=>59},{"id"=>60}]
|
44
50
|
|
45
51
|
result.each do |r|
|
46
52
|
status = connector.get_status(r['id'])
|
47
|
-
# => {"status"=>"delivered", "id"=>
|
53
|
+
# => {"status"=>"delivered", "id"=>58, "reference"=>"your-msg-id-001", "ts"=>"2015-03-26T10:55:06.098Z"}
|
48
54
|
|
49
55
|
# do sth with status
|
50
56
|
end
|
@@ -59,4 +65,4 @@ end
|
|
59
65
|
|
60
66
|
## Copyright
|
61
67
|
|
62
|
-
Copyright (c) 2015
|
68
|
+
Copyright (c) 2015 COMVERGA Sp. z o. o. See LICENSE for details.
|
@@ -27,18 +27,24 @@ module MprofiApiClient
|
|
27
27
|
@proxy_url = proxy_url
|
28
28
|
@messages = []
|
29
29
|
@clear_messages = true
|
30
|
+
@read_timeout = nil
|
30
31
|
end
|
31
32
|
|
32
33
|
# Add one message to message queue.
|
33
34
|
# +recipient+:: Message recipient as string (phone number format: XXXXXXXXX f.e. 664400100).
|
34
35
|
# +message+:: Message content as string.
|
35
36
|
# +reference+:: Client message ID defined by user for message tracking. (optional)
|
36
|
-
|
37
|
+
# +options+:: Message options: encoding (default: {}):
|
38
|
+
# +:encoding+ - set to 'utf-8' if you need special characters (diacritical marks, emoji),
|
39
|
+
# +:date+ - time the message will be sent (accepted formats: ISO-8601, unix epoch)
|
40
|
+
def add_message(recipient, message, reference = nil, options = {})
|
37
41
|
raise ArgumentError, "`recipient` cannot be empty" if recipient.nil? || recipient.empty?
|
38
42
|
raise ArgumentError, "`message` cannot be empty" if message.nil? || message.empty?
|
39
43
|
|
40
44
|
message = { 'recipient' => recipient, 'message' => message }
|
41
45
|
message['reference'] = reference if reference
|
46
|
+
message['encoding'] = options[:encoding] if options.key?(:encoding)
|
47
|
+
message['date'] = options[:date] if options.key?(:date)
|
42
48
|
|
43
49
|
@messages << message
|
44
50
|
end
|
@@ -80,6 +86,11 @@ module MprofiApiClient
|
|
80
86
|
return result
|
81
87
|
end
|
82
88
|
|
89
|
+
# Set read timeout
|
90
|
+
# +timeout+ - number of seconds
|
91
|
+
def read_timeout=(timeout)
|
92
|
+
@read_timeout = timeout
|
93
|
+
end
|
83
94
|
|
84
95
|
private
|
85
96
|
|
@@ -118,6 +129,8 @@ module MprofiApiClient
|
|
118
129
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
119
130
|
end
|
120
131
|
|
132
|
+
http.read_timeout = @read_timeout unless @read_timeout.nil?
|
133
|
+
|
121
134
|
result = http.request(request)
|
122
135
|
rescue Exception => err
|
123
136
|
raise MprofiConnectionError.new(err.message, err)
|
data/lib/mprofi_api_client.rb
CHANGED
data/mprofi_api_client.gemspec
CHANGED
@@ -8,10 +8,10 @@ Gem::Specification.new do |spec|
|
|
8
8
|
|
9
9
|
spec.summary = 'MProfi API client library'
|
10
10
|
spec.date = '2015-03-05'
|
11
|
-
spec.authors = ['
|
12
|
-
|
13
|
-
spec.email = '
|
14
|
-
spec.homepage = 'https://github.com/
|
11
|
+
spec.authors = ['COMVERGA Sp. z o. o.']
|
12
|
+
|
13
|
+
spec.email = 'pomoc@mprofi.pl'
|
14
|
+
spec.homepage = 'https://github.com/comverga/mprofi_api_client_ruby'
|
15
15
|
spec.description = spec.summary
|
16
16
|
spec.license = 'BSD'
|
17
17
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mprofi_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- COMVERGA Sp. z o. o.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: MProfi API client library
|
84
|
-
email:
|
84
|
+
email: pomoc@mprofi.pl
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/mprofi_api_client/connector.rb
|
95
95
|
- lib/mprofi_api_client/connector_exception.rb
|
96
96
|
- mprofi_api_client.gemspec
|
97
|
-
homepage: https://github.com/
|
97
|
+
homepage: https://github.com/comverga/mprofi_api_client_ruby
|
98
98
|
licenses:
|
99
99
|
- BSD
|
100
100
|
metadata: {}
|
@@ -113,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 2.4.6
|
116
|
+
rubygems_version: 3.1.6
|
118
117
|
signing_key:
|
119
118
|
specification_version: 4
|
120
119
|
summary: MProfi API client library
|