lpaisais-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27e87e156a81dd5451506f1bf4ac20e9012c7201
4
+ data.tar.gz: f9d02d48904c1b7d37a558290a9d05b351ce37d4
5
+ SHA512:
6
+ metadata.gz: d30fd86ea88664dee532ca5a79979122708b94dc2ffd6c782afc8cdcfba8bd43ceb4002f5db917d816211bb1bfa623149323c84315e1df4de65a313a3fedd5dd
7
+ data.tar.gz: 07547a05beedd21940330b7552b4496890834f3ebf22001d95accaef681af11dd38caab8f0ee38f965b035896122457dd5a32636f3359ae59f6b18d00a1adb2f
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lpaisais-api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Desk Rock
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Lpaisais::API
2
+
3
+ A ruby gem to access Latvian postal service address API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'lpaisais-api'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install lpaisais-api
18
+
19
+ ## Usage example
20
+
21
+ ``` ruby
22
+ require 'lpaisais/api'
23
+
24
+ # provide configuration information
25
+ Lpaisais::API.configure do |config|
26
+ config.wsdl = 'wsdl_url'
27
+ config.key = 'server_key'
28
+ end
29
+
30
+ # call without parameters, for initial data from server
31
+ Lpaisais::API.call
32
+ # => { "addr_elem_region" => [""], "addr_elem_city" => {...}, ... }
33
+
34
+ # call with parameters, Lpaisais::API.call(udpdate, data)
35
+ # - update (string or symbol): updated element, in this case :addr_elem_type
36
+ # - data (hash): information to query from server
37
+ response = Lpaisais::API.call(:addr_elem_type, { addr_elem_city: 178 })
38
+ # => { "addr_elem_region" => [""], "addr_elem_street" => {"0" => "Street X"}, ... }
39
+ ```
40
+
41
+ For further information on Lpaisais response structure, please visit the server's website.
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/lpaisais-api/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+
@@ -0,0 +1,34 @@
1
+ require 'savon'
2
+ require 'json'
3
+
4
+ module Lpaisais
5
+ module API
6
+ class Client
7
+ class << self
8
+ def call(update = nil, data = {})
9
+ fail InvalidConfiguration if Lpaisais::API.config[:wsdl].blank?
10
+ fail InvalidConfiguration if Lpaisais::API.config[:key].blank?
11
+ client = Savon.client(wsdl: Lpaisais::API.config[:wsdl])
12
+ body = { params: build_params(update, data) }
13
+ response = client.call(:lpaisais, message: body)
14
+ parse_response(response.body[:lpaisais_response][:return])
15
+ end
16
+
17
+ private
18
+
19
+ def build_params(update, data)
20
+ {
21
+ call: update,
22
+ type: :home,
23
+ data: data,
24
+ key: Lpaisais::API.config[:key]
25
+ }.to_json
26
+ end
27
+
28
+ def parse_response(response)
29
+ JSON.parse(response.gsub("'", '"'))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ module Lpaisais
2
+ module API
3
+ Configuration = Struct.new(:wsdl, :key) do
4
+ def initialize
5
+ self.wsdl = nil
6
+ self.key = nil
7
+ end
8
+ end
9
+
10
+ def self.configure
11
+ @config = Configuration.new
12
+ yield(@config) if block_given?
13
+ @config
14
+ end
15
+
16
+ def self.config
17
+ @config || configure
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module Lpaisais
2
+ module API
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require 'lpaisais/api/client'
2
+ require 'lpaisais/api/configuration'
3
+ require 'lpaisais/api/version'
4
+
5
+ module Lpaisais
6
+ module API
7
+ InvalidConfiguration = Class.new(StandardError)
8
+
9
+ def self.call(update = nil, data = {})
10
+ Client.call(update, data)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ require 'lpaisais/api'
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lpaisais/api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'lpaisais-api'
8
+ spec.version = Lpaisais::API::VERSION
9
+ spec.authors = %w(David\ Ochoa Stanislav\ Gorski)
10
+ spec.email = %w(ochoaqdavid@gmail.com stanislav.gorski@gmail.com)
11
+ spec.summary = %q{Latvian postal service address API gem}
12
+ spec.description = %q{A ruby gem to access Latvian postal service address API}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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 = %w(lib)
20
+
21
+ spec.add_dependency 'savon', '~> 2.6'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.6'
24
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lpaisais-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Ochoa
8
+ - Stanislav Gorski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-11-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.6'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.6'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.6'
42
+ description: A ruby gem to access Latvian postal service address API
43
+ email:
44
+ - ochoaqdavid@gmail.com
45
+ - stanislav.gorski@gmail.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/lpaisais-api.rb
56
+ - lib/lpaisais/api.rb
57
+ - lib/lpaisais/api/client.rb
58
+ - lib/lpaisais/api/configuration.rb
59
+ - lib/lpaisais/api/version.rb
60
+ - lpaisais-api.gemspec
61
+ homepage: ''
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.3
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Latvian postal service address API gem
85
+ test_files: []