moceansdk 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d60c2b5a6d3baee166f95851e6882d58ecff0bbca91855fa471d3cb5e129523e
4
- data.tar.gz: 0551d8738ac463a0ae9bf3e9a0836a5aa82302c40513d9e03d79126ccee29efd
3
+ metadata.gz: baa2fbc9440d656aee7a53d85dd3bac6be392cae9ac8559f41cf5e5c25694500
4
+ data.tar.gz: bb6c25ba828434a22b301decc6d5e1edb5f3c1e82c85182415dc09a8169a4564
5
5
  SHA512:
6
- metadata.gz: 29e7c9f0e5a578d8bc1f0bc1afce8ae3179a928a850677ea212bff9fdebb3c0a93d7f67e49f2294bdc5d5cfd3e315492653f9e87828d1c4296202ee8318b5922
7
- data.tar.gz: 489e052c4e49ac0ddf96a3d27411e2ca51c3cec7d05d02c84998c54d4fa0ce2cb3f9914a1fc49c5a6d1d3ec4952f147b05ae04627dcbc9118bae916442efc73c
6
+ metadata.gz: 516771c7d9ce1a9fa24ee023db3427e266abd89336bc15743f49f0877bffd5c03141eafa5867941cb95a8828d89647a7eef48232c185acb5b8b23c4fea80d270
7
+ data.tar.gz: cda8a8545f864c4717cc3efec9fcd29afe7b585b33c8bb99ddd9c7f69a0f44b13e6cfbc76c8d3883ef55bbffaaa1513ebb92bf0a8d86adba1b754c574a8447ee
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018-2019 Micro Ocean Technologies Sdn Bhd
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.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018-2019 Micro Ocean Technologies Sdn Bhd
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 CHANGED
@@ -1,74 +1,74 @@
1
- MoceanAPI Client Library for Ruby
2
- ============================
3
- [![Gem Version](https://img.shields.io/gem/v/moceansdk.svg)](https://rubygems.org/gems/moceansdk)
4
- [![build status](https://img.shields.io/travis/com/MoceanAPI/mocean-sdk-ruby.svg)](https://travis-ci.com/MoceanAPI/mocean-sdk-ruby)
5
- [![codecov](https://img.shields.io/codecov/c/github/MoceanAPI/mocean-sdk-ruby.svg)](https://codecov.io/gh/MoceanAPI/mocean-sdk-ruby)
6
- [![codacy](https://img.shields.io/codacy/grade/5d5f7f9e7b1c4e888636a244283bf6f7.svg)](https://app.codacy.com/project/MoceanAPI/mocean-sdk-ruby/dashboard)
7
- [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
8
- [![total downloads](https://img.shields.io/gem/dt/moceansdk.svg)](https://rubygems.org/gems/moceansdk)
9
-
10
- This is the Ruby client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up [for free at
11
- moceanapi.com][signup].
12
-
13
- * [Installation](#installation)
14
- * [Usage](#usage)
15
- * [Example](#example)
16
-
17
- ## Installation
18
-
19
- To use the client library you'll need to have [created a Mocean account][signup].
20
-
21
- To install the Ruby client library using Gem.
22
-
23
- ```bash
24
- gem install moceansdk
25
- ```
26
-
27
- ## Usage
28
-
29
- Create a client with your API key and secret:
30
-
31
- ```ruby
32
- require 'moceansdk'
33
-
34
- credential = Moceansdk::Auth::Basic.new("API_KEY_HERE", "API_SECRET_HERE")
35
- mocean = Moceansdk::Client.new(credential)
36
- ```
37
-
38
- ## Example
39
-
40
- To use [Mocean's SMS API][doc_sms] to send an SMS message, call the `mocean.sms.send()` method.
41
-
42
- The API can be called directly, using a simple array of parameters, the keys match the [parameters of the API][doc_sms].
43
-
44
- ```ruby
45
- res = mocean.sms.send({
46
- "mocean-text": 'Hello World',
47
- "mocean-from": 'MOCEAN',
48
- "mocean-to": '60123456789'
49
- })
50
-
51
- puts res
52
- ```
53
-
54
- ### Responses
55
-
56
- For your convenient, the API response has been parsed to `Hash` using [hash_dot](https://github.com/adsteel/hash_dot) package.
57
- ```ruby
58
- puts res # show full response string
59
- puts res.status # show response status, '0' in this case
60
- puts res['status'] # same as above
61
- ```
62
-
63
- ## Documentation
64
-
65
- Kindly visit [MoceanApi Docs][doc_main] for more usage
66
-
67
- ## License
68
-
69
- This library is released under the [MIT License][license]
70
-
71
- [signup]: https://dashboard.moceanapi.com/register?medium=github&campaign=sdk-ruby
72
- [doc_main]: https://moceanapi.com/docs/?ruby
73
- [doc_sms]: https://moceanapi.com/docs/?ruby#send-sms
74
- [license]: LICENSE.txt
1
+ MoceanAPI Client Library for Ruby
2
+ ============================
3
+ [![Gem Version](https://img.shields.io/gem/v/moceansdk.svg)](https://rubygems.org/gems/moceansdk)
4
+ [![build status](https://img.shields.io/travis/com/MoceanAPI/mocean-sdk-ruby.svg)](https://travis-ci.com/MoceanAPI/mocean-sdk-ruby)
5
+ [![codecov](https://img.shields.io/codecov/c/github/MoceanAPI/mocean-sdk-ruby.svg)](https://codecov.io/gh/MoceanAPI/mocean-sdk-ruby)
6
+ [![codacy](https://img.shields.io/codacy/grade/7564ecfa8e7948a7ba15cb7634258c7e.svg)](https://app.codacy.com/project/MoceanAPI/mocean-sdk-ruby/dashboard)
7
+ [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
8
+ [![total downloads](https://img.shields.io/gem/dt/moceansdk.svg)](https://rubygems.org/gems/moceansdk)
9
+
10
+ This is the Ruby client library for use Mocean's API. To use this, you'll need a Mocean account. Sign up [for free at
11
+ moceanapi.com][signup].
12
+
13
+ * [Installation](#installation)
14
+ * [Usage](#usage)
15
+ * [Example](#example)
16
+
17
+ ## Installation
18
+
19
+ To use the client library you'll need to have [created a Mocean account][signup].
20
+
21
+ To install the Ruby client library using Gem.
22
+
23
+ ```bash
24
+ gem install moceansdk
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Create a client with your API key and secret:
30
+
31
+ ```ruby
32
+ require 'moceansdk'
33
+
34
+ credential = Moceansdk::Auth::Basic.new("API_KEY_HERE", "API_SECRET_HERE")
35
+ mocean = Moceansdk::Client.new(credential)
36
+ ```
37
+
38
+ ## Example
39
+
40
+ To use [Mocean's SMS API][doc_sms] to send an SMS message, call the `mocean.sms.send()` method.
41
+
42
+ The API can be called directly, using a simple array of parameters, the keys match the [parameters of the API][doc_sms].
43
+
44
+ ```ruby
45
+ res = mocean.sms.send({
46
+ "mocean-text": 'Hello World',
47
+ "mocean-from": 'MOCEAN',
48
+ "mocean-to": '60123456789'
49
+ })
50
+
51
+ puts res
52
+ ```
53
+
54
+ ### Responses
55
+
56
+ For your convenient, the API response has been parsed to `Hash` using [hash_dot](https://github.com/adsteel/hash_dot) package.
57
+ ```ruby
58
+ puts res # show full response string
59
+ puts res.status # show response status, '0' in this case
60
+ puts res['status'] # same as above
61
+ ```
62
+
63
+ ## Documentation
64
+
65
+ Kindly visit [MoceanApi Docs][doc_main] for more usage
66
+
67
+ ## License
68
+
69
+ This library is released under the [MIT License][license]
70
+
71
+ [signup]: https://dashboard.moceanapi.com/register?medium=github&campaign=sdk-ruby
72
+ [doc_main]: https://moceanapi.com/docs/?ruby
73
+ [doc_sms]: https://moceanapi.com/docs/?ruby#send-sms
74
+ [license]: LICENSE.txt
data/lib/moceansdk.rb CHANGED
@@ -1,28 +1,28 @@
1
- require 'http'
2
- require 'json'
3
- require 'hash_dot'
4
- require 'xmlsimple'
5
-
6
- require 'moceansdk/auth/abstract_auth'
7
- require 'moceansdk/auth/basic'
8
- require 'moceansdk/exceptions/mocean_error'
9
- require 'moceansdk/exceptions/required_field_exception'
10
-
11
- require 'moceansdk/modules/abstact_client'
12
- require 'moceansdk/modules/response_factory'
13
- require 'moceansdk/modules/transmitter'
14
-
15
- require 'moceansdk/modules/account/balance'
16
- require 'moceansdk/modules/account/pricing'
17
-
18
- require 'moceansdk/modules/message/channel'
19
- require 'moceansdk/modules/message/message_status'
20
- require 'moceansdk/modules/message/sms'
21
- require 'moceansdk/modules/message/verify_request'
22
- require 'moceansdk/modules/message/verify_validate'
23
-
24
- require 'moceansdk/modules/number_lookup/number_lookup'
25
-
26
- require 'moceansdk/utils'
27
- require 'moceansdk/version'
1
+ require 'http'
2
+ require 'json'
3
+ require 'hash_dot'
4
+ require 'xmlsimple'
5
+
6
+ require 'moceansdk/auth/abstract_auth'
7
+ require 'moceansdk/auth/basic'
8
+ require 'moceansdk/exceptions/mocean_error'
9
+ require 'moceansdk/exceptions/required_field_exception'
10
+
11
+ require 'moceansdk/modules/abstact_client'
12
+ require 'moceansdk/modules/response_factory'
13
+ require 'moceansdk/modules/transmitter'
14
+
15
+ require 'moceansdk/modules/account/balance'
16
+ require 'moceansdk/modules/account/pricing'
17
+
18
+ require 'moceansdk/modules/message/channel'
19
+ require 'moceansdk/modules/message/message_status'
20
+ require 'moceansdk/modules/message/sms'
21
+ require 'moceansdk/modules/message/verify_request'
22
+ require 'moceansdk/modules/message/verify_validate'
23
+
24
+ require 'moceansdk/modules/number_lookup/number_lookup'
25
+
26
+ require 'moceansdk/utils'
27
+ require 'moceansdk/version'
28
28
  require 'moceansdk/client'
@@ -1,15 +1,15 @@
1
- module Moceansdk
2
- module Auth
3
-
4
- class AbstractAuth
5
- def auth_method
6
- raise NotImplementedError, 'AbstractAuth is a abstract class'
7
- end
8
-
9
- def params
10
- raise NotImplementedError, 'AbstractAuth is a abstract class'
11
- end
12
- end
13
-
14
- end
15
- end
1
+ module Moceansdk
2
+ module Auth
3
+
4
+ class AbstractAuth
5
+ def auth_method
6
+ raise NotImplementedError, 'AbstractAuth is a abstract class'
7
+ end
8
+
9
+ def params
10
+ raise NotImplementedError, 'AbstractAuth is a abstract class'
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -1,29 +1,29 @@
1
- module Moceansdk
2
- module Auth
3
-
4
- class Basic < AbstractAuth
5
- def initialize(api_key = nil, api_secret = nil)
6
- @params = {}
7
- @params['mocean-api-key'] = api_key unless api_key.nil?
8
- @params['mocean-api-secret'] = api_secret unless api_secret.nil?
9
- end
10
-
11
- def api_key=(api_key)
12
- @params['mocean-api-key'] = api_key
13
- end
14
-
15
- def api_secret=(api_secret)
16
- @params['mocean-api-secret'] = api_secret
17
- end
18
-
19
- def auth_method
20
- 'basic'
21
- end
22
-
23
- def params
24
- @params
25
- end
26
- end
27
-
28
- end
29
- end
1
+ module Moceansdk
2
+ module Auth
3
+
4
+ class Basic < AbstractAuth
5
+ def initialize(api_key = nil, api_secret = nil)
6
+ @params = {}
7
+ @params['mocean-api-key'] = api_key unless api_key.nil?
8
+ @params['mocean-api-secret'] = api_secret unless api_secret.nil?
9
+ end
10
+
11
+ def api_key=(api_key)
12
+ @params['mocean-api-key'] = api_key
13
+ end
14
+
15
+ def api_secret=(api_secret)
16
+ @params['mocean-api-secret'] = api_secret
17
+ end
18
+
19
+ def auth_method
20
+ 'basic'
21
+ end
22
+
23
+ def params
24
+ @params
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -1,62 +1,62 @@
1
- module Moceansdk
2
-
3
- class Client
4
- def initialize(obj_auth, options = nil)
5
- unless obj_auth.is_a? Auth::AbstractAuth
6
- raise Exceptions::MoceanError, 'auth object must extend AbstractAuth'
7
- end
8
-
9
- if obj_auth.auth_method.casecmp('basic').zero?
10
- if Utils.nil_or_empty?(obj_auth.params['mocean-api-key']) || Utils.nil_or_empty?(obj_auth.params['mocean-api-secret'])
11
- raise Exceptions::RequiredFieldException, "api key and api secret for client object can't be empty"
12
- end
13
- else
14
- raise Exceptions::MoceanError, 'unsupported auth method'
15
- end
16
-
17
- @transmitter = if options.is_a? Modules::Transmitter
18
- options
19
- else
20
- Modules::Transmitter.new(options)
21
- end
22
-
23
- @obj_auth = obj_auth
24
- end
25
-
26
- def sms
27
- Modules::Message::Sms.new(@obj_auth, @transmitter)
28
- end
29
-
30
- def flash_sms
31
- sms = Modules::Message::Sms.new(@obj_auth, @transmitter)
32
- sms.mclass = 1
33
- sms.alt_dcs = 1
34
- sms
35
- end
36
-
37
- def pricing
38
- Modules::Account::Pricing.new(@obj_auth, @transmitter)
39
- end
40
-
41
- def balance
42
- Modules::Account::Balance.new(@obj_auth, @transmitter)
43
- end
44
-
45
- def message_status
46
- Modules::Message::MessageStatus.new(@obj_auth, @transmitter)
47
- end
48
-
49
- def verify_request
50
- Modules::Message::VerifyRequest.new(@obj_auth, @transmitter)
51
- end
52
-
53
- def verify_validate
54
- Modules::Message::VerifyValidate.new(@obj_auth, @transmitter)
55
- end
56
-
57
- def number_lookup
58
- Modules::NumberLookup::NumberLookup.new(@obj_auth, @transmitter)
59
- end
60
- end
61
-
62
- end
1
+ module Moceansdk
2
+
3
+ class Client
4
+ def initialize(obj_auth, options = nil)
5
+ unless obj_auth.is_a? Auth::AbstractAuth
6
+ raise Exceptions::MoceanError, 'auth object must extend AbstractAuth'
7
+ end
8
+
9
+ if obj_auth.auth_method.casecmp('basic').zero?
10
+ if Utils.nil_or_empty?(obj_auth.params['mocean-api-key']) || Utils.nil_or_empty?(obj_auth.params['mocean-api-secret'])
11
+ raise Exceptions::RequiredFieldException, "api key and api secret for client object can't be empty"
12
+ end
13
+ else
14
+ raise Exceptions::MoceanError, 'unsupported auth method'
15
+ end
16
+
17
+ @transmitter = if options.is_a? Modules::Transmitter
18
+ options
19
+ else
20
+ Modules::Transmitter.new(options)
21
+ end
22
+
23
+ @obj_auth = obj_auth
24
+ end
25
+
26
+ def sms
27
+ Modules::Message::Sms.new(@obj_auth, @transmitter)
28
+ end
29
+
30
+ def flash_sms
31
+ sms = Modules::Message::Sms.new(@obj_auth, @transmitter)
32
+ sms.mclass = 1
33
+ sms.alt_dcs = 1
34
+ sms
35
+ end
36
+
37
+ def pricing
38
+ Modules::Account::Pricing.new(@obj_auth, @transmitter)
39
+ end
40
+
41
+ def balance
42
+ Modules::Account::Balance.new(@obj_auth, @transmitter)
43
+ end
44
+
45
+ def message_status
46
+ Modules::Message::MessageStatus.new(@obj_auth, @transmitter)
47
+ end
48
+
49
+ def verify_request
50
+ Modules::Message::VerifyRequest.new(@obj_auth, @transmitter)
51
+ end
52
+
53
+ def verify_validate
54
+ Modules::Message::VerifyValidate.new(@obj_auth, @transmitter)
55
+ end
56
+
57
+ def number_lookup
58
+ Modules::NumberLookup::NumberLookup.new(@obj_auth, @transmitter)
59
+ end
60
+ end
61
+
62
+ end