apispree_api 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +26 -0
- data/README.md +16 -0
- data/app/controllers/admin/users_controller_decorator.rb +19 -0
- data/app/controllers/api/adjustments_controller.rb +13 -0
- data/app/controllers/api/analyses_controller.rb +134 -0
- data/app/controllers/api/base_controller.rb +187 -0
- data/app/controllers/api/checkout1_controller.rb +4 -0
- data/app/controllers/api/countries_controller.rb +14 -0
- data/app/controllers/api/images_controller.rb +15 -0
- data/app/controllers/api/inventory_units_controller.rb +19 -0
- data/app/controllers/api/line_items_controller.rb +37 -0
- data/app/controllers/api/mail_methods_controller.rb +10 -0
- data/app/controllers/api/option_types_controller.rb +24 -0
- data/app/controllers/api/orders_controller.rb +51 -0
- data/app/controllers/api/payment_methods_controller.rb +24 -0
- data/app/controllers/api/payments_controller.rb +3 -0
- data/app/controllers/api/product_groups_controller.rb +14 -0
- data/app/controllers/api/products_controller.rb +25 -0
- data/app/controllers/api/promotions_controller.rb +14 -0
- data/app/controllers/api/properties_controller.rb +26 -0
- data/app/controllers/api/prototypes_controller.rb +24 -0
- data/app/controllers/api/reports_controller.rb +8 -0
- data/app/controllers/api/shipments_controller.rb +37 -0
- data/app/controllers/api/shipping_categories_controller.rb +13 -0
- data/app/controllers/api/shipping_methods_controller.rb +24 -0
- data/app/controllers/api/states_controller.rb +19 -0
- data/app/controllers/api/tax_categories_controller.rb +24 -0
- data/app/controllers/api/tax_rates_controller.rb +24 -0
- data/app/controllers/api/taxonomies_controller.rb +12 -0
- data/app/controllers/api/taxons_controller.rb +17 -0
- data/app/controllers/api/users_controller.rb +3 -0
- data/app/controllers/api/variants_controller.rb +24 -0
- data/app/controllers/api/zones_controller.rb +24 -0
- data/app/models/line_item_decorator.rb +7 -0
- data/app/models/order_decorator.rb +5 -0
- data/app/models/shipment_decorator.rb +5 -0
- data/app/models/user_decorator.rb +22 -0
- data/app/views/admin/users/_api_fields.html.erb +16 -0
- data/config/cucumber.yml +10 -0
- data/config/locales/en.yml +16 -0
- data/config/routes.rb +144 -0
- data/db/migrate/20100107141738_add_api_key_to_users.rb +9 -0
- data/lib/apispree_api.rb +16 -0
- data/lib/spree_api_hooks.rb +3 -0
- data/lib/tasks/install.rake +23 -0
- metadata +112 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
class Api::VariantsController < Api::BaseController
|
2
|
+
|
3
|
+
# Looks like this action is unused
|
4
|
+
# def filtered
|
5
|
+
# @properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
|
6
|
+
# respond_with(@properties) do |format|
|
7
|
+
# format.html { render :template => "spree/admin/properties/filtered", :formats => [:html], :handlers => [:erb], :layout => false }
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
public
|
13
|
+
def destroy
|
14
|
+
puts "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
15
|
+
puts params[object_name]
|
16
|
+
puts params[:id]
|
17
|
+
@object=Variant.find_by_id(params[:id])
|
18
|
+
@object.destroy
|
19
|
+
if @object.destroy
|
20
|
+
render :text => 'Destroyed'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Api::ZonesController < Api::BaseController
|
2
|
+
|
3
|
+
# Looks like this action is unused
|
4
|
+
# def filtered
|
5
|
+
# @properties = Property.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%").order(:name)
|
6
|
+
# respond_with(@properties) do |format|
|
7
|
+
# format.html { render :template => "spree/admin/properties/filtered", :formats => [:html], :handlers => [:erb], :layout => false }
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
public
|
13
|
+
def destroy
|
14
|
+
puts "&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&"
|
15
|
+
puts params[object_name]
|
16
|
+
puts params[:id]
|
17
|
+
@object=Zone.find_by_id(params[:id])
|
18
|
+
@object.destroy
|
19
|
+
if @object.destroy
|
20
|
+
render :text => 'Destroyed'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
User.class_eval do
|
2
|
+
|
3
|
+
def clear_api_key!
|
4
|
+
self.update_attribute(:authentication_token, "")
|
5
|
+
end
|
6
|
+
|
7
|
+
def generate_api_key!
|
8
|
+
self.reset_authentication_token!
|
9
|
+
end
|
10
|
+
|
11
|
+
#def self.authenticate_with_http(username, password)
|
12
|
+
# logger.debug(username)
|
13
|
+
# self.authenticate_with_token(:auth_token => username)
|
14
|
+
#end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def secure_digest(*args)
|
19
|
+
Digest::SHA1.hexdigest(args.flatten.join('--'))
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2><%= t('api.access') %></h2>
|
2
|
+
|
3
|
+
<% if @user.authentication_token.present? %>
|
4
|
+
<p><strong><%= t('api.key') %></strong> <%= @user.authentication_token %></p>
|
5
|
+
<%= form_tag clear_api_key_admin_user_path(@user), :method => :put do %>
|
6
|
+
<%= button t("api.clear_key") %>
|
7
|
+
<% end %>
|
8
|
+
<%= form_tag generate_api_key_admin_user_path(@user), :method => :put do %>
|
9
|
+
<%= button t("api.regenerate_key") %>
|
10
|
+
<% end %>
|
11
|
+
<% else %>
|
12
|
+
<p><%= t('api.no_key') %></p>
|
13
|
+
<%= form_tag generate_api_key_admin_user_path(@user), :method => :put do %>
|
14
|
+
<%= button t("api.generate_key") %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
|
5
|
+
ci_opts = "--format progress --strict"
|
6
|
+
%>
|
7
|
+
default: <%= std_opts %> features
|
8
|
+
wip: --tags @wip:3 --wip features
|
9
|
+
ci: <%= ci_opts %> features CI=true
|
10
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
api: "API"
|
4
|
+
api:
|
5
|
+
access: "API Access"
|
6
|
+
clear_key: "Clear API key"
|
7
|
+
errors:
|
8
|
+
invalid_event: "Invalid event name, valid names are %{events}"
|
9
|
+
invalid_event_for_object: "Valid event name but not allowed for this object, valid names are %{events}"
|
10
|
+
missing_event: "No event name supplied"
|
11
|
+
generate_key: "Generate API key"
|
12
|
+
key: "API Key"
|
13
|
+
regenerate_key: "Regenerate API key"
|
14
|
+
no_key: "No key defined"
|
15
|
+
key_generated: "API key generated"
|
16
|
+
key_cleared: "API key cleared"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
namespace :admin do
|
3
|
+
resources :users do
|
4
|
+
member do
|
5
|
+
put :generate_api_key
|
6
|
+
put :clear_api_key
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :api do
|
12
|
+
resources :taxonomies
|
13
|
+
match '/t/*id', :to => 'taxons#show', :as => :nested_taxons
|
14
|
+
resources :taxonomies do
|
15
|
+
member do
|
16
|
+
get :get_children
|
17
|
+
end
|
18
|
+
resources :taxons
|
19
|
+
end
|
20
|
+
resources :adjustments
|
21
|
+
resources :shipping_categories
|
22
|
+
resources :shipping_methods
|
23
|
+
resources :promotions
|
24
|
+
# resources :promotions do
|
25
|
+
# # resources :promotion_rules
|
26
|
+
# # resources :promotion_actions
|
27
|
+
# end
|
28
|
+
resources :tax_categories
|
29
|
+
resources :zones
|
30
|
+
# resources :payments do
|
31
|
+
# member do
|
32
|
+
# put :fire
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
resources :product_groups
|
36
|
+
resources :tax_rates
|
37
|
+
resources :payment_methods
|
38
|
+
resources :variants
|
39
|
+
resources :products do
|
40
|
+
resources :product_properties
|
41
|
+
resources :images do
|
42
|
+
collection do
|
43
|
+
post :update_positions
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
resources :shipments, :except => [:new,:edit] do
|
49
|
+
put :event, :on => :member
|
50
|
+
resources :inventory_units, :except => [:new,:edit] do
|
51
|
+
put :event, :on => :member
|
52
|
+
end
|
53
|
+
end
|
54
|
+
resources :creditcards
|
55
|
+
resources :creditcard_payments
|
56
|
+
resources :option_types
|
57
|
+
resources :properties
|
58
|
+
resources :prototypes
|
59
|
+
resources :shipping_methods
|
60
|
+
resources :mail_methods do
|
61
|
+
member do
|
62
|
+
post :testmail
|
63
|
+
end
|
64
|
+
end
|
65
|
+
resources :reports, :only => [:index, :show] do
|
66
|
+
collection do
|
67
|
+
get :sales_total
|
68
|
+
end
|
69
|
+
end
|
70
|
+
match '/user/sign_in',:to=>"user_sessions#new"
|
71
|
+
match '/checkout/update/:state' => 'checkout1#update', :as => :update_checkout ,:via=>:put
|
72
|
+
#match '/checkout/update/:state', :to => 'checkout#update_order',:via=>:put
|
73
|
+
#match '/checkout/:state', :to => 'checkout#edit', :as => :checkout_state, :via => :get
|
74
|
+
#match '/checkout', :to => 'checkout#edit', :state => 'address', :as => :checkout
|
75
|
+
#match '/checkout/payment', :to => 'checkout#payment', :via => :put
|
76
|
+
match '/analyses/best_selling_products', :to => 'analyses#best_selling_products', :via => :get
|
77
|
+
match '/analyses/gross_selling_products', :to => 'analyses#gross_selling_products', :via => :get
|
78
|
+
match '/analyses/top_spenders', :to => 'analyses#top_spenders', :via => :get
|
79
|
+
match '/analyses/recent_orders', :to => 'analyses#recent_orders', :via => :get
|
80
|
+
match '/analyses/out_of_stock', :to => 'analyses#out_of_stock', :via => :get
|
81
|
+
match '/analyses/day_order_count', :to => 'analyses#day_order_count', :via => :get
|
82
|
+
match '/analyses/day_order_value', :to => 'analyses#day_order_value', :via => :get
|
83
|
+
match '/analyses/month_order_value', :to => 'analyses#month_order_value', :via => :get
|
84
|
+
match '/analyses/month_order_count', :to => 'analyses#month_order_count', :via => :get
|
85
|
+
match '/products/add',:to=>'products#add',:via=>:post
|
86
|
+
#match '/products/remove',:to=>'products#remove',:via=>:delete
|
87
|
+
# resources :images
|
88
|
+
resources :orders, :except => [:new,:edit] do
|
89
|
+
put :event, :on => :member
|
90
|
+
resources :shipments, :except => [:new,:edit]
|
91
|
+
resources :line_items, :except => [:new,:edit]
|
92
|
+
resources :inventory_units, :except => [:new,:edit] do
|
93
|
+
put :event, :on => :member
|
94
|
+
end
|
95
|
+
end
|
96
|
+
resources :line_items,:only=>[:create]
|
97
|
+
resources :inventory_units, :except => [:new,:edit] do
|
98
|
+
put :event, :on => :member
|
99
|
+
end
|
100
|
+
resources :users , :except => [:new,:edit]
|
101
|
+
resources :user_sessions do
|
102
|
+
put :event, :on => :member
|
103
|
+
end
|
104
|
+
resources :products, :except => [:new,:edit] do
|
105
|
+
member do
|
106
|
+
delete :remove
|
107
|
+
end
|
108
|
+
end
|
109
|
+
resources :orders do
|
110
|
+
member do
|
111
|
+
put :fire
|
112
|
+
get :fire
|
113
|
+
post :resend
|
114
|
+
get :history
|
115
|
+
get :user
|
116
|
+
end
|
117
|
+
|
118
|
+
resources :adjustments
|
119
|
+
resources :line_items
|
120
|
+
resources :shipments do
|
121
|
+
member do
|
122
|
+
put :fire
|
123
|
+
end
|
124
|
+
end
|
125
|
+
resources :return_authorizations do
|
126
|
+
member do
|
127
|
+
put :fire
|
128
|
+
end
|
129
|
+
end
|
130
|
+
resources :payments do
|
131
|
+
member do
|
132
|
+
put :fire
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
resources :countries
|
137
|
+
resources :countries do
|
138
|
+
resources :states
|
139
|
+
end
|
140
|
+
resources :states
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
data/lib/apispree_api.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'apispree_core'
|
2
|
+
require 'spree_api_hooks'
|
3
|
+
|
4
|
+
module SpreeApi
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
def self.activate
|
7
|
+
|
8
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
9
|
+
Rails.env.production? ? require(c) : load(c)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
14
|
+
config.to_prepare &method(:activate).to_proc
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :apispree_api do
|
2
|
+
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
+
task :install do
|
4
|
+
Rake::Task['apispree_api:install:migrations'].invoke
|
5
|
+
Rake::Task['apispree_api:install:assets'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :install do
|
9
|
+
|
10
|
+
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
11
|
+
task :migrations do
|
12
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
13
|
+
destination = File.join(Rails.root, 'db')
|
14
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
18
|
+
task :assets do
|
19
|
+
# No assets
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apispree_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ! "Santosh kumar mohanty\t"
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: apispree_core
|
16
|
+
requirement: &78566330 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *78566330
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: apispree_auth
|
27
|
+
requirement: &78566040 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *78566040
|
36
|
+
description: Required dependancy for API-Spree
|
37
|
+
email: santa.jyp@gmail.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
- app/models/shipment_decorator.rb
|
45
|
+
- app/models/user_decorator.rb
|
46
|
+
- app/models/line_item_decorator.rb
|
47
|
+
- app/models/order_decorator.rb
|
48
|
+
- app/controllers/admin/users_controller_decorator.rb
|
49
|
+
- app/controllers/api/variants_controller.rb
|
50
|
+
- app/controllers/api/adjustments_controller.rb
|
51
|
+
- app/controllers/api/promotions_controller.rb
|
52
|
+
- app/controllers/api/tax_rates_controller.rb
|
53
|
+
- app/controllers/api/line_items_controller.rb
|
54
|
+
- app/controllers/api/payments_controller.rb
|
55
|
+
- app/controllers/api/prototypes_controller.rb
|
56
|
+
- app/controllers/api/base_controller.rb
|
57
|
+
- app/controllers/api/product_groups_controller.rb
|
58
|
+
- app/controllers/api/shipments_controller.rb
|
59
|
+
- app/controllers/api/shipping_categories_controller.rb
|
60
|
+
- app/controllers/api/tax_categories_controller.rb
|
61
|
+
- app/controllers/api/reports_controller.rb
|
62
|
+
- app/controllers/api/images_controller.rb
|
63
|
+
- app/controllers/api/zones_controller.rb
|
64
|
+
- app/controllers/api/states_controller.rb
|
65
|
+
- app/controllers/api/shipping_methods_controller.rb
|
66
|
+
- app/controllers/api/analyses_controller.rb
|
67
|
+
- app/controllers/api/products_controller.rb
|
68
|
+
- app/controllers/api/taxons_controller.rb
|
69
|
+
- app/controllers/api/properties_controller.rb
|
70
|
+
- app/controllers/api/inventory_units_controller.rb
|
71
|
+
- app/controllers/api/option_types_controller.rb
|
72
|
+
- app/controllers/api/taxonomies_controller.rb
|
73
|
+
- app/controllers/api/users_controller.rb
|
74
|
+
- app/controllers/api/orders_controller.rb
|
75
|
+
- app/controllers/api/payment_methods_controller.rb
|
76
|
+
- app/controllers/api/countries_controller.rb
|
77
|
+
- app/controllers/api/mail_methods_controller.rb
|
78
|
+
- app/controllers/api/checkout1_controller.rb
|
79
|
+
- app/views/admin/users/_api_fields.html.erb
|
80
|
+
- config/cucumber.yml
|
81
|
+
- config/routes.rb
|
82
|
+
- config/locales/en.yml
|
83
|
+
- lib/apispree_api.rb
|
84
|
+
- lib/spree_api_hooks.rb
|
85
|
+
- lib/tasks/install.rake
|
86
|
+
- db/migrate/20100107141738_add_api_key_to_users.rb
|
87
|
+
homepage: http://spreecommerce.com
|
88
|
+
licenses: []
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.8.7
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements:
|
106
|
+
- none
|
107
|
+
rubyforge_project: apispree_api
|
108
|
+
rubygems_version: 1.8.17
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: Provides RESTful access for API-Spree.
|
112
|
+
test_files: []
|