oneapi-ruby 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 +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.md +102 -0
- data/Rakefile +8 -0
- data/examples/example_customer_profile.rb +29 -0
- data/examples/example_get_hlr.rb +34 -0
- data/examples/example_get_inbound_messages.rb +26 -0
- data/examples/example_on_inbound_message.rb +13 -0
- data/examples/example_send_hlr_and_wait_for_delivery_push.rb +50 -0
- data/examples/example_send_message_and_check_delivery_status.rb +53 -0
- data/examples/example_send_message_and_wait_for_delivery_push.rb +56 -0
- data/lib/oneapi-ruby.rb +8 -0
- data/lib/oneapi-ruby/client.rb +309 -0
- data/lib/oneapi-ruby/models.rb +205 -0
- data/lib/oneapi-ruby/objects.rb +174 -0
- data/lib/oneapi-ruby/utils.rb +164 -0
- data/lib/oneapi-ruby/version.rb +3 -0
- data/oneapi-ruby.gemspec +23 -0
- data/test/test.rb +69 -0
- metadata +93 -0
data/oneapi-ruby.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'oneapi-ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "oneapi-ruby"
|
8
|
+
spec.version = OneApi::VERSION
|
9
|
+
spec.authors = ["Tomo Krajina"]
|
10
|
+
spec.email = ["tkrajina@gmail.com"]
|
11
|
+
spec.description = %q{OneApi Ruby client}
|
12
|
+
spec.summary = %q{OneApi Ruby client}
|
13
|
+
spec.homepage = "https://github.com/infobip/oneapi-ruby"
|
14
|
+
spec.license = "Apache"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/test/test.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'oneapi/client'
|
3
|
+
|
4
|
+
class OneApiTest < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_empty
|
7
|
+
assert_equal OneApi::Utils.empty(0), true
|
8
|
+
assert_equal OneApi::Utils.empty(1), false
|
9
|
+
assert_equal OneApi::Utils.empty('aaa'), false
|
10
|
+
assert_equal OneApi::Utils.empty(0.0), true
|
11
|
+
assert_equal OneApi::Utils.empty([]), true
|
12
|
+
assert_equal OneApi::Utils.empty([1]), false
|
13
|
+
assert_equal OneApi::Utils.empty({}), true
|
14
|
+
assert_equal OneApi::Utils.empty({'a' => 1}), false
|
15
|
+
assert_equal OneApi::Utils.empty(''), true
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_json_get
|
19
|
+
json = '{"requestError":{"serviceException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":[""]},"policyException":null}}'
|
20
|
+
request_error = OneApi::JSONUtils.get(json, 'requestError.serviceException.text')
|
21
|
+
assert_equal('Request URI missing required component(s): ', request_error)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_json_get_hash_result
|
25
|
+
json = '{"requestError":{"serviceException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":[""]},"policyException":null}}'
|
26
|
+
value = OneApi::JSONUtils.get(json, 'requestError.serviceException')
|
27
|
+
puts value.inspect
|
28
|
+
assert_equal(value, {"messageId"=>"SVC0002", "variables"=>[""], "text"=>"Request URI missing required component(s): "})
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_json_get_array_in_path
|
32
|
+
json = '{"requestError":{"serviceException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":["abc", "cde"]},"policyException":null}}'
|
33
|
+
value = OneApi::JSONUtils.get(json, 'requestError.serviceException.variables.1')
|
34
|
+
assert_equal(value, "cde")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_json_get_with_or_paths
|
38
|
+
json = '{"requestError":{"serviceException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":["abc", "cde"]},"policyException":null}}'
|
39
|
+
value = OneApi::JSONUtils.get(json, 'requestError.serviceException.messageId | requestError.policyException.messageId')
|
40
|
+
assert_equal(value, "SVC0002")
|
41
|
+
|
42
|
+
json = '{"requestError":{"policyException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":["abc", "cde"]},"serviceException":null}}'
|
43
|
+
value = OneApi::JSONUtils.get(json, 'requestError.serviceException.messageId | requestError.policyException.messageId')
|
44
|
+
assert_equal(value, "SVC0002")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_exception_serialization
|
48
|
+
json = '{"requestError":{"serviceException":{"text":"Request URI missing required component(s): ","messageId":"SVC0002","variables":[""]},"policyException":null}}'
|
49
|
+
|
50
|
+
sms_exception = OneApi::Conversions.from_json(OneApi::OneApiError, json, nil)
|
51
|
+
|
52
|
+
assert(sms_exception)
|
53
|
+
assert_equal(sms_exception.message_id, 'SVC0002')
|
54
|
+
assert_equal(sms_exception.text, 'Request URI missing required component(s): ')
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_exception_object_array
|
58
|
+
json = '{"deliveryInfoList":{"deliveryInfo":[{"address":null,"deliveryStatus":"DeliveryUncertain1"},{"address":null,"deliveryStatus":"DeliveryUncertain2"}],"resourceURL":"http://oneapi.infobip.com/1/smsmessaging/outbound/TODO/requests/28drx7ypaqr/deliveryInfos"}}'
|
59
|
+
|
60
|
+
object = OneApi::Conversions.from_json(OneApi::DeliveryInfoList, json, nil)
|
61
|
+
|
62
|
+
assert(object)
|
63
|
+
assert(object.delivery_info)
|
64
|
+
assert_equal(2, object.delivery_info.length)
|
65
|
+
assert_equal("DeliveryUncertain1", object.delivery_info[0].delivery_status)
|
66
|
+
assert_equal("DeliveryUncertain2", object.delivery_info[1].delivery_status)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oneapi-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomo Krajina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-04 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: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
description: OneApi Ruby client
|
42
|
+
email:
|
43
|
+
- tkrajina@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- examples/example_customer_profile.rb
|
54
|
+
- examples/example_get_hlr.rb
|
55
|
+
- examples/example_get_inbound_messages.rb
|
56
|
+
- examples/example_on_inbound_message.rb
|
57
|
+
- examples/example_send_hlr_and_wait_for_delivery_push.rb
|
58
|
+
- examples/example_send_message_and_check_delivery_status.rb
|
59
|
+
- examples/example_send_message_and_wait_for_delivery_push.rb
|
60
|
+
- lib/oneapi-ruby.rb
|
61
|
+
- lib/oneapi-ruby/client.rb
|
62
|
+
- lib/oneapi-ruby/models.rb
|
63
|
+
- lib/oneapi-ruby/objects.rb
|
64
|
+
- lib/oneapi-ruby/utils.rb
|
65
|
+
- lib/oneapi-ruby/version.rb
|
66
|
+
- oneapi-ruby.gemspec
|
67
|
+
- test/test.rb
|
68
|
+
homepage: https://github.com/infobip/oneapi-ruby
|
69
|
+
licenses:
|
70
|
+
- Apache
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.0.3
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: OneApi Ruby client
|
92
|
+
test_files:
|
93
|
+
- test/test.rb
|