torg_mail_api_client 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a43bdf3cf864c1d401c00815fb5d27c908f20fb
4
+ data.tar.gz: 22890269f7922f79c47c815d8134db16da423514
5
+ SHA512:
6
+ metadata.gz: e80df9b6c8df8b14b44cea264b3be0b1645699919aaa432e24534ff41d678ea53410afd1d8b64c079140518361e263b45dd11d008fef66f4ab53a3ab669b3fd3
7
+ data.tar.gz: a4d87c7ac0c786f43fd17e7caa5efc58f14967011685c58acd0ecd95d094d87a6636e106c553bb50446dfce158399a43016e08a826525b741c472d821e6bfab4
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest', '~> 5.0.0'
6
+ gem 'webmock'
7
+ gem 'coveralls', require: false
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ torg_mail_api_client (0.0.1)
5
+ weary
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.4.0)
11
+ coveralls (0.8.10)
12
+ json (~> 1.8)
13
+ rest-client (>= 1.6.8, < 2)
14
+ simplecov (~> 0.11.0)
15
+ term-ansicolor (~> 1.3)
16
+ thor (~> 0.19.1)
17
+ tins (~> 1.6.0)
18
+ crack (0.4.3)
19
+ safe_yaml (~> 1.0.0)
20
+ docile (1.1.5)
21
+ domain_name (0.5.25)
22
+ unf (>= 0.0.5, < 1.0.0)
23
+ hashdiff (0.2.3)
24
+ http-cookie (1.0.2)
25
+ domain_name (~> 0.5)
26
+ json (1.8.3)
27
+ mime-types (2.99)
28
+ minitest (5.0.8)
29
+ multi_json (1.11.2)
30
+ netrc (0.11.0)
31
+ promise (0.3.1)
32
+ rack (1.6.4)
33
+ rake (10.5.0)
34
+ rest-client (1.8.0)
35
+ http-cookie (>= 1.0.2, < 2.0)
36
+ mime-types (>= 1.16, < 3.0)
37
+ netrc (~> 0.7)
38
+ safe_yaml (1.0.4)
39
+ simple_oauth (0.3.1)
40
+ simplecov (0.11.1)
41
+ docile (~> 1.1.0)
42
+ json (~> 1.8)
43
+ simplecov-html (~> 0.10.0)
44
+ simplecov-html (0.10.0)
45
+ term-ansicolor (1.3.2)
46
+ tins (~> 1.0)
47
+ thor (0.19.1)
48
+ tins (1.6.0)
49
+ unf (0.1.4)
50
+ unf_ext
51
+ unf_ext (0.0.7.1)
52
+ weary (1.1.3)
53
+ addressable (~> 2.3)
54
+ multi_json (~> 1.7)
55
+ promise (~> 0.3.0)
56
+ rack (~> 1.5)
57
+ simple_oauth (~> 0.2)
58
+ webmock (1.22.6)
59
+ addressable (>= 2.3.6)
60
+ crack (>= 0.3.2)
61
+ hashdiff
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ coveralls
68
+ minitest (~> 5.0.0)
69
+ rake
70
+ torg_mail_api_client!
71
+ webmock
72
+
73
+ BUNDLED WITH
74
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Igor Kuznetsov
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # torg_mail_api_client
2
+ Client to work with Torg Mail API
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+ #Bundler::GemHelper.install_tasks
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "test"
8
+ t.test_files = FileList['test/lib/**/*_test.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ desc "Runinng tests"
13
+ task :default => :test
@@ -0,0 +1,22 @@
1
+ require 'torg_mail_api_client/version'
2
+
3
+ require 'weary'
4
+
5
+ module TorgMailApiClient
6
+
7
+ autoload :Config, 'torg_mail_api_client/config'
8
+ autoload :Client, 'torg_mail_api_client/client'
9
+
10
+ def self.get_client
11
+ Client.new
12
+ end
13
+
14
+ def self.configure
15
+ yield(config)
16
+ end
17
+
18
+ def self.config
19
+ @config ||= Config.new
20
+ end
21
+
22
+ end
@@ -0,0 +1,26 @@
1
+ module TorgMailApiClient
2
+ class Client < ::Weary::Client
3
+ domain TorgMailApiClient.config.host
4
+
5
+ def initialize(format = nil)
6
+ headers("Authorization" => TorgMailApiClient.config.auth_key)
7
+ end
8
+
9
+ class << self
10
+ def config
11
+ TorgMailApiClient.config
12
+ end
13
+
14
+ def format
15
+ config.format
16
+ end
17
+ end
18
+
19
+ get :shop_reviews, "/#{config.api_version}/seller/{shop_id}/reviews.#{format}" do |resource|
20
+ resource.required :shop_id
21
+ resource.optional :page, :sort, # default sort date
22
+ :sort_order, # default order desc
23
+ :results_per_page, :mark # default results 0, mark - all
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ module TorgMailApiClient
2
+ class Config
3
+ attr_accessor :auth_key, :api_version, :format, :host
4
+
5
+ def api_version
6
+ @apiversion ||= '1.0'
7
+ end
8
+
9
+ def format
10
+ @format ||= 'json'
11
+ end
12
+
13
+ def host
14
+ "http://content.api.torg.mail.ru"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module TorgMailApiClient
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,52 @@
1
+ {
2
+ "SellerOpinions": {
3
+ "ResultsTotal": 40,
4
+ "ResultsPerPage": 5,
5
+ "Page": 1,
6
+ "Listing": [
7
+ {
8
+ "Id": 1,
9
+ "Date": "1452071513",
10
+ "Text": "\u0417\u0430\u043a\u0430\u0437\u0430\u043b\u0430",
11
+ "Mark": 1,
12
+ "Usefull": 1,
13
+ "Useless": 0
14
+ },
15
+
16
+ {
17
+ "Id": 2,
18
+ "Date": "1451293795",
19
+ "Text": "\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442",
20
+ "Mark": 1,
21
+ "Usefull": 7,
22
+ "Useless": 1
23
+ },
24
+
25
+ {
26
+ "Id": 3,
27
+ "Date": "1450456488",
28
+ "Text": "\u041b\u041e\u0425\u041e\u0422\u0420\u041e\u041d\r\n\r\n\u042f\u0432\u043b\u044f\u044f\u0441\u044c",
29
+ "Mark": 1,
30
+ "Usefull": 10,
31
+ "Useless": 0
32
+ },
33
+
34
+ {
35
+ "Id": 4,
36
+ "Date": "1449303582",
37
+ "Text": "26 \u043d\u043e\u044f\u0431\u0440\u044f",
38
+ "Mark": 1,
39
+ "Usefull": 15,
40
+ "Useless": 1
41
+ },
42
+ {
43
+ "Id": 5,
44
+ "Date": "1449152014",
45
+ "Text": "\u041f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c",
46
+ "Mark": 3,
47
+ "Usefull": 6,
48
+ "Useless": 1
49
+ }
50
+ ]
51
+ }
52
+ }
@@ -0,0 +1,10 @@
1
+ module ConfigurationHelper
2
+
3
+ def standart_configuration
4
+ TorgMailApiClient.configure do |config|
5
+ config.auth_key = "123"
6
+ config.api_version = "1.0"
7
+ config.host = "http://test.com"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ module FixturesHelper
2
+
3
+ def load_fixture(filename)
4
+ File.read(File.dirname(__FILE__) + "/../" + "fixtures/#{filename}")
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ require 'test_helper'
2
+
3
+ class ClientTest < TestCase
4
+
5
+ def setup
6
+ standart_configuration
7
+ end
8
+
9
+ def test_should_get_instance
10
+ @client = TorgMailApiClient.get_client
11
+ assert_kind_of(TorgMailApiClient::Client, @client)
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class ShopResourceTest < TestCase
5
+
6
+ def setup
7
+ standart_configuration
8
+ @client = TorgMailApiClient.get_client
9
+
10
+ @return = { headers: {
11
+ 'Authorization' => TorgMailApiClient.config.auth_key,
12
+ 'content-type' => 'application/json; charset=utf-8'
13
+ } }
14
+ @shop_url = TorgMailApiClient.config.host + "/#{TorgMailApiClient.config.api_version}/seller/%s"
15
+ end
16
+
17
+ def test_getting_shop_reviews
18
+ stub = stub_request(:get, @shop_url % '1' + '/reviews.json').
19
+ to_return(@return.merge(body: load_fixture('shop_reviews.json')))
20
+
21
+ @client.shop_reviews(shop_id: 1).perform.parse
22
+ end
23
+ end
@@ -0,0 +1,29 @@
1
+ require 'bundler/setup'
2
+ Bundler.require
3
+
4
+ require 'minitest/autorun'
5
+ require 'webmock/minitest'
6
+
7
+ # colorize test output
8
+ require 'minitest/pride'
9
+ Minitest::PrideIO.pride!
10
+
11
+ require 'coveralls'
12
+ Coveralls.wear! do
13
+ add_filter '/test/'
14
+ end
15
+
16
+ Bundler.require
17
+
18
+ # requiring helpers
19
+ Dir[ File.join( File.dirname(__FILE__), "helpers/*.rb")].each { |file| require file }
20
+
21
+ class TestCase < Minitest::Test
22
+
23
+ include ConfigurationHelper
24
+ include FixturesHelper
25
+
26
+ end
27
+
28
+ # requiring all project files for correct coverage
29
+ Dir[ File.join( File.dirname(__FILE__), "../lib/**/*.rb")].each { |file| require file }
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'torg_mail_api_client/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "torg_mail_api_client"
8
+ gem.version = TorgMailApiClient::VERSION
9
+ gem.authors = ["Igor Kuznetsov"]
10
+ gem.email = ["igkuznetsov@gmail.com"]
11
+ gem.description = %q{Torg Mail API client written in Ruby}
12
+ gem.summary = %q{It's a wrapper for TorgMail Api calls written in Ruby. Useful for clients having authoriztion key from Mail.ru.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "weary"
21
+ gem.add_development_dependency "rake"
22
+ gem.required_ruby_version = '~> 2.0'
23
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: torg_mail_api_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Igor Kuznetsov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: weary
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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: Torg Mail API client written in Ruby
42
+ email:
43
+ - igkuznetsov@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - lib/torg_mail_api_client.rb
55
+ - lib/torg_mail_api_client/client.rb
56
+ - lib/torg_mail_api_client/config.rb
57
+ - lib/torg_mail_api_client/version.rb
58
+ - test/fixtures/shop_reviews.json
59
+ - test/helpers/configuration_helper.rb
60
+ - test/helpers/fixtures_helper.rb
61
+ - test/lib/torg_mail_api_client/client_test.rb
62
+ - test/lib/torg_mail_api_client/shop_resource_test.rb
63
+ - test/test_helper.rb
64
+ - torg_mail_api_client.gemspec
65
+ homepage: ''
66
+ licenses: []
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '2.0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.0.14.1
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: It's a wrapper for TorgMail Api calls written in Ruby. Useful for clients
88
+ having authoriztion key from Mail.ru.
89
+ test_files:
90
+ - test/fixtures/shop_reviews.json
91
+ - test/helpers/configuration_helper.rb
92
+ - test/helpers/fixtures_helper.rb
93
+ - test/lib/torg_mail_api_client/client_test.rb
94
+ - test/lib/torg_mail_api_client/shop_resource_test.rb
95
+ - test/test_helper.rb