ecwid_gateway 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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ *.swp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.3-p194@ecwid_gateway --create
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ecwid_gateway.gemspec
4
+ gemspec
5
+
6
+ gem 'weary'
7
+
8
+ group :development, :test do
9
+ gem 'webmock'
10
+ gem 'json'
11
+ gem 'minitest'
12
+ gem 'turn'
13
+ gem 'tconsole'
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Andrey Kumanyaev
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,29 @@
1
+ # EcwidGateway
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ecwid_gateway'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ecwid_gateway
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ecwid_gateway/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ecwid_gateway"
8
+ gem.version = EcwidGateway::VERSION
9
+ gem.authors = ["Andrey Kumanyaev"]
10
+ gem.email = ["me@zzet.org"]
11
+ gem.description = %q{Ecwid API wrapper}
12
+ gem.summary = %q{Some summary}
13
+ gem.homepage = ""
14
+
15
+ gem.add_dependency 'weary'
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,93 @@
1
+ require "weary/client"
2
+
3
+ module EcwidGateway
4
+ class Client < Weary::Client
5
+
6
+ required :store_id
7
+ domain EcwidGateway.options[:api_domain]
8
+
9
+ def initialize(attrs = {})
10
+ attrs = EcwidGateway.options.merge(attrs)
11
+ Config::VALID_OPTIONS_KEYS.each do |key|
12
+ instance_variable_set("@#{key}".to_sym, attrs[key])
13
+ end
14
+ end
15
+
16
+ #Product_API
17
+
18
+ get :categories_request, '/api/v1/:store_id/categories' do |resource|
19
+ resource.required :store_id, :parent
20
+ end
21
+
22
+ get :products_request, '/api/v1/:store_id/products' do |resource|
23
+ resource.required :store_id, :category
24
+ end
25
+
26
+ get :product_request, '/api/v1/:store_id/product' do |resource|
27
+ resource.required :store_id, :id
28
+ end
29
+
30
+ get :random_products_request, '/api/v1/:store_id/random_products' do |resource|
31
+ resource.required :store_id, :count
32
+ end
33
+
34
+ get :profile_request, '/api/v1/:store_id/profile' do |resource|
35
+ resource.required :store_id
36
+ end
37
+
38
+ get :batch_request, '/api/v1/:store_id/batch' do |resource|
39
+ # TODO: Implement
40
+ end
41
+
42
+ # Order_API
43
+
44
+ get :orders_request, 'api/v1/:store_id/orders' do |resource|
45
+ resource.required :store_id, :secure_auth_key
46
+ resource.optional :date, :from_date, :to_date,
47
+ :from_update_date, :to_update_date,
48
+ :order, :from_order, :to_order,
49
+ :customer_id, :customer_email,
50
+ :statuses,
51
+ :limit,
52
+ :offset
53
+ end
54
+
55
+ post :orders_request, 'api/v1/:store_id/orders' do |resource|
56
+ # TODO: Implement
57
+ resource.required :store_id, :secure_auth_key
58
+ resource.optional :date, :from_date, :to_date,
59
+ :from_update_date, :to_update_date,
60
+ :order, :from_order, :to_order,
61
+ :customer_id, :customer_email,
62
+ :statuses,
63
+ :limit,
64
+ :offset
65
+ end
66
+
67
+ def get_categories(category = 0)
68
+ request = categories_request({:store_id => @store_id, :parent => category}).perform
69
+ request.body
70
+ end
71
+
72
+ def get_products(category)
73
+ request = products_request({:store_id => @store_id, :category => category}).perform
74
+ request.body
75
+ end
76
+
77
+ def get_product(product)
78
+ request = product_request({:store_id => @store_id, :id => product}).perform
79
+ request.body
80
+ end
81
+
82
+ def get_random_products(count)
83
+ request = random_products_request({:store_id => @store_id, :count => count}).perform
84
+ request.body
85
+ end
86
+
87
+ def get_profile
88
+ request = profile_request({:store_id => @store_id}).perform
89
+ request.body
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,49 @@
1
+ module EcwidGateway
2
+ module Config
3
+
4
+ # Defaultapi domain
5
+ DEFAULT_API_DOMAIN = 'http://127.0.0.1:80'
6
+
7
+ # Defailt api token
8
+ DEFAULT_STORE_ID = nil
9
+
10
+ # Valid options keys
11
+ VALID_OPTIONS_KEYS = [
12
+ :store_id,
13
+ :api_domain,
14
+ :order_secure_auth_key,
15
+ :sso_secure_auth_key
16
+ ]
17
+
18
+ # Valid options accessor
19
+ attr_accessor *VALID_OPTIONS_KEYS
20
+
21
+ def self.extended(base)
22
+ base.reset
23
+ end
24
+
25
+ def configure
26
+ yield self
27
+ self
28
+ end
29
+
30
+ # Create a hash of options and their values
31
+ #
32
+ # @return [Hash]
33
+ def options
34
+ options = {}
35
+ VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
36
+ options
37
+ end
38
+
39
+ # Reset config
40
+ #
41
+ # @return [self]
42
+ def reset
43
+ self.store_id = DEFAULT_STORE_ID
44
+ self.api_domain = DEFAULT_API_DOMAIN
45
+ self
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module EcwidGateway
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "ecwid_gateway/version"
2
+
3
+ module EcwidGateway
4
+
5
+ autoload :Client, "ecwid_gateway/client"
6
+ autoload :Config, "ecwid_gateway/config"
7
+
8
+ extend Config
9
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ecwid_gateway
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrey Kumanyaev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: weary
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Ecwid API wrapper
31
+ email:
32
+ - me@zzet.org
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - .rvmrc
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - ecwid_gateway.gemspec
44
+ - lib/ecwid_gateway.rb
45
+ - lib/ecwid_gateway/client.rb
46
+ - lib/ecwid_gateway/config.rb
47
+ - lib/ecwid_gateway/version.rb
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Some summary
72
+ test_files: []