edesky-client 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: a5d2abe471a35f4380ced646a9fa214b07c83606
4
+ data.tar.gz: 2368b2c312e54b8b3016b4b29de498d495d5ccc8
5
+ SHA512:
6
+ metadata.gz: c3c2213c3a55952b940b4a240f746de5ec607c2163c9c54a99fbbc3def7f728c6ae9072ff5965deeb97d0af40688e0e716089194320eae7ca377e503215fb971
7
+ data.tar.gz: af2c0a1c95470dc937c96caaa6b8a28f1872f3dcb75b85d2c094ea118ef70de6c146923f980dcb0ca885888c77289004d693854564b9b215aa1c0105c2bc96cd
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle
2
+ /log/*
3
+ .idea
4
+ .rvmrc
5
+ /nbproject
6
+ /.nbproject
7
+ .DS_Store
8
+ .*~
9
+ .~lock.*#
10
+ .directory
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ Ruby klient pro edesky.cz API
2
+ ============================
3
+
4
+ **Ve vývoji.**
5
+
6
+ Informace o obecném HTTP API najdete na https://github.com/edesky/edesky_api
7
+
8
+ Příklad použití
9
+ ---------------
10
+
11
+ ```bash
12
+ gem install edesky-client
13
+ ```
14
+
15
+ ```ruby
16
+ require 'edesky_client'
17
+
18
+ client = EdeskyClient.new(api_key: '')
19
+
20
+ response = client.query_documents(keywords: 'prodej')
21
+
22
+ # vypsat prvni nalezeny dokument
23
+ p response['documents']['document'][0]
24
+ ```
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'edesky-client'
3
+ s.version = '0.0.1'
4
+ s.date = '2015-11-21'
5
+ s.summary = "Ruby klient pro edesky.cz API"
6
+ s.description = "Ruby klient pro edesky.cz HTTP API, hledání dokumentů a úředních desek."
7
+ s.authors = ["Marek Aufart"]
8
+ s.email = 'aufi.cz@gmail.com'
9
+ s.files = `git ls-files`.split($\)
10
+ s.test_files = s.files.grep(%r{spec/})
11
+ s.require_paths = ["lib"]
12
+ s.homepage = 'https://github.com/edesky/edeskyclient_ruby'
13
+ s.license = 'MIT'
14
+ s.required_ruby_version = '>= 1.9.3'
15
+
16
+ s.add_dependency 'simplexml', '~> 1.1'
17
+ s.add_development_dependency 'minitest', '~> 5.0'
18
+ end
@@ -0,0 +1,66 @@
1
+ # The MIT License (MIT)
2
+ # Copyright (c) 2015 Marek Aufart, edesky.cz
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ # The above copyright notice and this permission notice shall be included in all
10
+ # copies or substantial portions of the Software.
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ # SOFTWARE.
18
+
19
+ require 'net/http'
20
+ require 'xmlsimple'
21
+
22
+ class EdeskyClient
23
+
24
+ CLIENT_DEFAULTS = {
25
+ endpoint_url: 'https://edesky.cz/api/v1/',
26
+ api_key: ''
27
+ }
28
+
29
+ DOC_QUERY_DEFAULTS = {
30
+ keywords: '*',
31
+ include_texts: 0
32
+ }
33
+
34
+ BOARD_QUERY_DEFAULTS = {}
35
+
36
+ def initialize(options = {})
37
+ CLIENT_DEFAULTS.merge(options).each do |option, value|
38
+ instance_variable_set("@#{option}", value)
39
+ end
40
+ end
41
+
42
+ def query_documents(options = {})
43
+ fetch('documents', DOC_QUERY_DEFAULTS.merge(options))
44
+ end
45
+
46
+ def query_dashboards(options = {})
47
+ raise "Not implemented yet!"
48
+ end
49
+
50
+ private
51
+
52
+ def fetch(type, params)
53
+ uri = URI(URI.join(@endpoint_url, type))
54
+ uri.query = URI.encode_www_form(params)
55
+ XmlSimple.xml_in(Net::HTTP.get(uri), 'ForceArray': false)
56
+ end
57
+
58
+ end
59
+
60
+ =begin
61
+ # Example:
62
+ client = EdeskyClient.new(api_key: '')
63
+ response = client.query_documents(keywords: 'prodej')
64
+ # print first found document
65
+ p response['documents']['document'][0]
66
+ =end
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="utf-8"?><edesky_search_api version="0.9">
2
+ <meta>
3
+ <timestamp>2015-08-01 07:31:12 +0200</timestamp>
4
+ <user>marek@aurem.cz</user>
5
+ <requested_params>{"keywords"=>"prodej", "created_from"=>"2015-06-01", "order"=>"date", "search_with"=>"sql", "api_key"=>"cs9r20T5rDr9dEFW1N9IFv8fpH7YN4PF", "page"=>"1", "format"=>"xml"}</requested_params>
6
+ <documents_count total="1622">200</documents_count>
7
+ <page total="9">1</page>
8
+ </meta>
9
+ <documents>
10
+ <document created_at="2015-07-31 17:19:39 +0200" dashboard_id="385" dashboard_name="Město Hluk" edesky_id="191444" edesky_text_url="https://edesky.cz/dokument/191444.txt" edesky_url="https://edesky.cz/dokument/191444" name="Zveřejněno 31.07.2015 - Záměr o prodeji části pozemků v ulici Pod Sádkama a v ulici Mladá.pdf" orig_url="http://www.mestohluk.cz/doc/930/element/67173/download">
11
+ <attachments>
12
+ <attachment contains_text="1" edesky_id="212424" mimetype="application/pdf" name="Zveřejněno 31.07.2015 - Záměr o prodeji části pozemků v ulici Pod Sádkama a v ulici Mladá.pdf" url="https://edesky.cz/attachments/2015_w30/385_212424/open-uri20150731-11087-ffz5q5">
13
+
14
+ </attachment>
15
+ </attachments>
16
+ </document>
17
+ <document created_at="2015-07-31 17:19:24 +0200" dashboard_id="362" dashboard_name="Město Holýšov" edesky_id="191436" edesky_text_url="https://edesky.cz/dokument/191436.txt" edesky_url="https://edesky.cz/dokument/191436" name="Výběrové řízení-prodej nemovitosti č.p.38 Vránov" orig_url="http://www.mestoholysov.cz/uredni-deska/vyberove-rizeni-prodej-nemovitosti-cp38-vranov-278.html">
18
+ <attachments>
19
+ <attachment contains_text="1" edesky_id="212398" mimetype="application/pdf" name="Výběrové řízení-prodej nemovitosti č.p.38 Vránov" url="https://edesky.cz/attachments/2015_w30/362_212398/open-uri20150731-11087-kmgf98">
20
+
21
+ </attachment>
22
+ </attachments>
23
+ </document>
24
+ </documents>
25
+ </edesky_search_api>
@@ -0,0 +1,13 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/edesky_client'
3
+
4
+ # client test
5
+ class TestEdeskyClient < Minitest::Test
6
+ def setup
7
+ @client = EdeskyClient.new
8
+ end
9
+
10
+ def test_get_documents
11
+ raise "TODO tests"
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: edesky-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marek Aufart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: simplexml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ description: Ruby klient pro edesky.cz HTTP API, hledání dokumentů a úředních desek.
42
+ email: aufi.cz@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - README.md
49
+ - edesky-client.gemspec
50
+ - lib/edesky_client.rb
51
+ - test/documents_output.xml
52
+ - test/test_edesky_client.rb
53
+ homepage: https://github.com/edesky/edeskyclient_ruby
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.9.3
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.4.5.1
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Ruby klient pro edesky.cz API
77
+ test_files: []