insales_api 0.0.13 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/CHANGELOG.md +20 -0
  4. data/Gemfile +1 -1
  5. data/README.md +57 -0
  6. data/Rakefile +8 -1
  7. data/insales_api.gemspec +12 -12
  8. data/lib/insales/controller/autologin.rb +45 -0
  9. data/lib/insales/controller/base_helpers.rb +52 -0
  10. data/lib/insales/controller/installer_actions.rb +19 -0
  11. data/lib/insales/controller/session_actions.rb +39 -0
  12. data/lib/insales/controller.rb +10 -0
  13. data/lib/insales.rb +7 -0
  14. data/lib/insales_api/account.rb +1 -9
  15. data/lib/insales_api/active_resource_proxy.rb +31 -0
  16. data/lib/insales_api/app.rb +57 -38
  17. data/lib/insales_api/application_charge.rb +3 -0
  18. data/lib/insales_api/asset.rb +3 -1
  19. data/lib/insales_api/base.rb +41 -5
  20. data/lib/insales_api/category.rb +8 -2
  21. data/lib/insales_api/client.rb +3 -1
  22. data/lib/insales_api/client_group.rb +3 -0
  23. data/lib/insales_api/collect.rb +8 -2
  24. data/lib/insales_api/discount_code.rb +3 -0
  25. data/lib/insales_api/helpers/has_insales_object.rb +34 -0
  26. data/lib/insales_api/helpers/init_api.rb +98 -0
  27. data/lib/insales_api/image.rb +5 -0
  28. data/lib/insales_api/order.rb +13 -5
  29. data/lib/insales_api/order_line.rb +2 -2
  30. data/lib/insales_api/product.rb +3 -1
  31. data/lib/insales_api/product_field.rb +3 -0
  32. data/lib/insales_api/product_field_value.rb +22 -0
  33. data/lib/insales_api/property.rb +3 -0
  34. data/lib/insales_api/resource/countable.rb +9 -0
  35. data/lib/insales_api/resource/paginated.rb +26 -0
  36. data/lib/insales_api/resource/with_updated_since.rb +28 -0
  37. data/lib/insales_api/theme.rb +7 -1
  38. data/lib/insales_api/variant.rb +18 -6
  39. data/lib/insales_api/version.rb +7 -1
  40. data/lib/insales_api.rb +74 -17
  41. data/spec/lib/insales_api/active_resource_proxy_spec.rb +59 -0
  42. data/spec/lib/insales_api/app_spec.rb +67 -0
  43. data/spec/lib/insales_api_spec.rb +110 -0
  44. data/spec/spec_helper.rb +3 -4
  45. metadata +54 -20
  46. data/README +0 -32
  47. data/spec/lib/insales_app_spec.rb +0 -63
metadata CHANGED
@@ -1,84 +1,112 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insales_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - InSales
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-23 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activeresource
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 2.13.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.3'
55
69
  description: Gem for accessing the InSales REST web services
56
70
  email: dg@insales.ru
57
71
  executables: []
58
72
  extensions: []
59
73
  extra_rdoc_files: []
60
74
  files:
61
- - .gitignore
75
+ - ".gitignore"
76
+ - ".travis.yml"
62
77
  - CHANGELOG.md
63
78
  - Gemfile
64
- - README
79
+ - README.md
65
80
  - Rakefile
66
81
  - insales_api.gemspec
67
82
  - lib/active_resource/singleton.rb
83
+ - lib/insales.rb
84
+ - lib/insales/controller.rb
85
+ - lib/insales/controller/autologin.rb
86
+ - lib/insales/controller/base_helpers.rb
87
+ - lib/insales/controller/installer_actions.rb
88
+ - lib/insales/controller/session_actions.rb
68
89
  - lib/insales_api.rb
69
90
  - lib/insales_api/account.rb
91
+ - lib/insales_api/active_resource_proxy.rb
70
92
  - lib/insales_api/app.rb
93
+ - lib/insales_api/application_charge.rb
71
94
  - lib/insales_api/application_widget.rb
72
95
  - lib/insales_api/asset.rb
73
96
  - lib/insales_api/base.rb
74
97
  - lib/insales_api/category.rb
75
98
  - lib/insales_api/client.rb
99
+ - lib/insales_api/client_group.rb
76
100
  - lib/insales_api/collect.rb
77
101
  - lib/insales_api/collection.rb
78
102
  - lib/insales_api/delivery_variant.rb
103
+ - lib/insales_api/discount_code.rb
79
104
  - lib/insales_api/domain.rb
80
105
  - lib/insales_api/field.rb
81
106
  - lib/insales_api/file.rb
107
+ - lib/insales_api/helpers/has_insales_object.rb
108
+ - lib/insales_api/helpers/init_api.rb
109
+ - lib/insales_api/image.rb
82
110
  - lib/insales_api/js_tag.rb
83
111
  - lib/insales_api/option_name.rb
84
112
  - lib/insales_api/option_value.rb
@@ -88,14 +116,22 @@ files:
88
116
  - lib/insales_api/password.rb
89
117
  - lib/insales_api/payment_gateway.rb
90
118
  - lib/insales_api/product.rb
119
+ - lib/insales_api/product_field.rb
120
+ - lib/insales_api/product_field_value.rb
121
+ - lib/insales_api/property.rb
91
122
  - lib/insales_api/recurring_application_charge.rb
123
+ - lib/insales_api/resource/countable.rb
124
+ - lib/insales_api/resource/paginated.rb
125
+ - lib/insales_api/resource/with_updated_since.rb
92
126
  - lib/insales_api/theme.rb
93
127
  - lib/insales_api/variant.rb
94
128
  - lib/insales_api/version.rb
95
129
  - lib/insales_api/webhook.rb
96
- - spec/lib/insales_app_spec.rb
130
+ - spec/lib/insales_api/active_resource_proxy_spec.rb
131
+ - spec/lib/insales_api/app_spec.rb
132
+ - spec/lib/insales_api_spec.rb
97
133
  - spec/spec_helper.rb
98
- homepage: http://wiki.insales.ru/wiki/%D0%9A%D0%B0%D0%BA_%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D1%82%D1%8C%D1%81%D1%8F_%D1%81_InSales
134
+ homepage: https://github.com/insales/insales_api
99
135
  licenses: []
100
136
  metadata: {}
101
137
  post_install_message:
@@ -104,20 +140,18 @@ require_paths:
104
140
  - lib
105
141
  required_ruby_version: !ruby/object:Gem::Requirement
106
142
  requirements:
107
- - - '>='
143
+ - - ">="
108
144
  - !ruby/object:Gem::Version
109
145
  version: '0'
110
146
  required_rubygems_version: !ruby/object:Gem::Requirement
111
147
  requirements:
112
- - - '>='
148
+ - - ">="
113
149
  - !ruby/object:Gem::Version
114
150
  version: '0'
115
151
  requirements: []
116
152
  rubyforge_project: insales_api
117
- rubygems_version: 2.0.3
153
+ rubygems_version: 2.2.2
118
154
  signing_key:
119
155
  specification_version: 4
120
156
  summary: Gem for accessing the InSales REST web services
121
- test_files:
122
- - spec/lib/insales_app_spec.rb
123
- - spec/spec_helper.rb
157
+ test_files: []
data/README DELETED
@@ -1,32 +0,0 @@
1
- # InsalesApi gem
2
-
3
- Insales api client based on [ActiveResource](https://github.com/rails/activeresource).
4
-
5
- Rails application example is [here](https://github.com/insales/insales_app).
6
-
7
- ## Install
8
-
9
- Add to Gemfile:
10
-
11
- ```ruby
12
- gem 'insales_api'
13
- ```
14
-
15
- ## Initialize
16
-
17
- ```ruby
18
- class MyApp < InsalesApi::App
19
- self.api_key = 'api_key'
20
- end
21
-
22
- MyApp.configure_api('domain', 'password')
23
- ```
24
-
25
- ## Use
26
-
27
- ```ruby
28
- order = InsaleApi::Order.find 123
29
-
30
- # singleton resources
31
- account = InsaleApi::Account.find
32
- ```
@@ -1,63 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe InsalesApi::App do
4
-
5
- let :app do
6
- InsalesApi::App.new('my.shop.com', 'password')
7
- end
8
-
9
- describe "initialize" do
10
- it { app.shop.should be }
11
- it { app.password.should be }
12
- it { app.should_not be_authorized }
13
- end
14
-
15
- describe "configure_api" do
16
- it 'should set site and password for InsalesApi' do
17
- app.configure_api
18
- InsalesApi::Base.site.to_s.should =~ /#{app.shop}/
19
- InsalesApi::Base.password.should == app.password
20
- end
21
- end
22
-
23
- describe "salt" do
24
- it "should return md5 hexdigest" do
25
- app.salt.should be
26
- app.salt.length.should == Digest::MD5.hexdigest('test').length
27
- end
28
- end
29
-
30
- describe "store_auth_token" do
31
- it "should set auth_token" do
32
- app.store_auth_token.should == InsalesApi::Password.create(app.password, app.salt)
33
- end
34
- end
35
-
36
- describe "authorization_url" do
37
- it "should set auth_token and return url" do
38
- app.authorization_url.should == "http://#{app.shop}/admin/applications/#{InsalesApi::App.api_key}/login?token=#{app.salt}&login=http://#{InsalesApi::App.api_host}/#{InsalesApi::App.api_autologin_path}"
39
- app.auth_token.should be
40
- end
41
- end
42
-
43
- describe "authorize" do
44
- before :each do
45
- app.store_auth_token
46
- end
47
- it "should authorize by valid token" do
48
- app.authorize app.auth_token
49
- app.should be_authorized
50
- end
51
-
52
- it "should not authorize by invalid token" do
53
- app.authorize 'bad token'
54
- app.should_not be_authorized
55
- end
56
- end
57
-
58
- describe "password_by_token" do
59
- it "should generate password" do
60
- InsalesApi::App.password_by_token('test').should == InsalesApi::Password.create(InsalesApi::App.api_secret, 'test')
61
- end
62
- end
63
- end