magento_rest_api 0.1.4 → 0.1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +62 -0
- data/README.md +33 -5
- data/bin/authenticate +42 -0
- data/lib/magento_rest_api/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bf269ff6826682f97ec0abe3f352df1d57ea10d
|
4
|
+
data.tar.gz: 7af27aef372924ada3937b2ce49891a288490ed2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75948fa22cef0afbe844a9d7e7fdff2541083a907fea99cde66e4b4f9f41c25d2bea973277d81d3043c58389dd99e6ad44aa066e1d071e0be1823168cd3c2432
|
7
|
+
data.tar.gz: d1f958c82284c4b338e2e3bba4aeae79fef8f9a6cd2ea78e2ce71a9e0b29066bc68d6f5a283c93e258d9b9abe4d8864e76b17fdd9bae10433c5d18e53bf473eb
|
data/.gitignore
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
<<<<<<< HEAD
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
=======
|
12
|
+
*.gem
|
13
|
+
*.rbc
|
14
|
+
/.config
|
15
|
+
/coverage/
|
16
|
+
/InstalledFiles
|
17
|
+
/pkg/
|
18
|
+
/spec/reports/
|
19
|
+
/spec/examples.txt
|
20
|
+
/test/tmp/
|
21
|
+
/test/version_tmp/
|
22
|
+
/tmp/
|
23
|
+
|
24
|
+
# Used by dotenv library to load environment variables.
|
25
|
+
# .env
|
26
|
+
|
27
|
+
## Specific to RubyMotion:
|
28
|
+
.dat*
|
29
|
+
.repl_history
|
30
|
+
build/
|
31
|
+
*.bridgesupport
|
32
|
+
build-iPhoneOS/
|
33
|
+
build-iPhoneSimulator/
|
34
|
+
|
35
|
+
## Specific to RubyMotion (use of CocoaPods):
|
36
|
+
#
|
37
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
38
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
39
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
40
|
+
#
|
41
|
+
# vendor/Pods/
|
42
|
+
|
43
|
+
## Documentation cache and generated files:
|
44
|
+
/.yardoc/
|
45
|
+
/_yardoc/
|
46
|
+
/doc/
|
47
|
+
/rdoc/
|
48
|
+
|
49
|
+
## Environment normalization:
|
50
|
+
/.bundle/
|
51
|
+
/vendor/bundle
|
52
|
+
/lib/bundler/man/
|
53
|
+
|
54
|
+
# for a library or gem, you might want to ignore these files since the code is
|
55
|
+
# intended to run in multiple environments; otherwise, check them in:
|
56
|
+
# Gemfile.lock
|
57
|
+
# .ruby-version
|
58
|
+
# .ruby-gemset
|
59
|
+
|
60
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
61
|
+
.rvmrc
|
62
|
+
>>>>>>> 651151105c09d1217fe3528d56d13bb90a6b2250
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# MagentoRestApi
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
This Gem will enable you to communicate to the rest api of magento 1.9.x
|
4
|
+
Beware of the limitations of the ruby 1.9.x restfull service.
|
5
|
+
The Soap service is much more extensive.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,35 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
You first need to authenticate this app to your magento by running the command
|
26
|
+
```sh
|
27
|
+
% authenticate
|
28
|
+
```
|
29
|
+
|
30
|
+
Use the above information to connect to the rest api after this you can do a get post put request.
|
31
|
+
GET request (get product information):
|
32
|
+
|
33
|
+
```irb
|
34
|
+
% irb
|
35
|
+
>> keys = {"consumer_key"=>"your_consumer_key", "consumer_secret"=>"your_consumer_secret", "token"=>"your_token", "token_secret"=>"your_token_secret"}
|
36
|
+
>> json_response = MagentoRestApi::connect('GET','https://your magento/api/rest/products/200', keys)
|
37
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
38
|
+
```
|
39
|
+
|
40
|
+
POST request (assign product to website):
|
41
|
+
|
42
|
+
```irb
|
43
|
+
% irb
|
44
|
+
>> keys = {"consumer_key"=>"your_consumer_key", "consumer_secret"=>"your_consumer_secret", "token"=>"your_token", "token_secret"=>"your_token_secret"}
|
45
|
+
>> post_data = {'website_id' => 1 }.to_json
|
46
|
+
>> json_response = MagentoRestApi::connect('POST','https://your magento/api/rest/products/200/websites', keys, post_data)
|
47
|
+
=> #<Net::HTTPOK 200 OK readbody=true>
|
48
|
+
```
|
49
|
+
|
50
|
+
PUT requests work in the same way as POST requests
|
51
|
+
|
52
|
+
more information about magento's REST API: http://devdocs.magento.com/guides/m1x/api/rest/introduction.html
|
53
|
+
I cannot stress enough to first find out if the API provides enough information for you.
|
26
54
|
|
27
55
|
## Development
|
28
56
|
|
@@ -32,7 +60,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
60
|
|
33
61
|
## Contributing
|
34
62
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Daniel304/magento_rest_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
64
|
|
37
65
|
|
38
66
|
## License
|
data/bin/authenticate
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'oauth'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
# fill out your key/secret admin user/password
|
8
|
+
auth={}
|
9
|
+
puts "Enter the magneto domain you wish to authenticate to (like: https://www.domain.com):"
|
10
|
+
url = gets.strip
|
11
|
+
|
12
|
+
puts "Enter your consumer key:"
|
13
|
+
auth["consumer_key"] = gets.strip
|
14
|
+
|
15
|
+
puts "Enter your consumer secret:"
|
16
|
+
auth["consumer_secret"] = gets.strip
|
17
|
+
|
18
|
+
puts "Your application is now set up, but you need to register"
|
19
|
+
puts "this instance of it with your user account."
|
20
|
+
|
21
|
+
@consumer=OAuth::Consumer.new auth["consumer_key"],
|
22
|
+
auth["consumer_secret"],
|
23
|
+
:request_token_path => '/oauth/initiate',
|
24
|
+
:authorize_path => '/admin/oauth_authorize',
|
25
|
+
:access_token_path => '/oauth/token',
|
26
|
+
:site => url
|
27
|
+
|
28
|
+
@request_token = @consumer.get_request_token
|
29
|
+
|
30
|
+
puts "Visit the following URL, log in if you need to, and authorize the app"
|
31
|
+
puts @request_token.authorize_url
|
32
|
+
puts "When you've authorized the token, enter the verifier code you are assigned:"
|
33
|
+
verifier = gets.strip
|
34
|
+
puts "Converting request token into access token..."
|
35
|
+
@access_token=@request_token.get_access_token(:oauth_verifier => verifier)
|
36
|
+
|
37
|
+
auth["token"] = @access_token.token
|
38
|
+
auth["token_secret"] = @access_token.secret
|
39
|
+
|
40
|
+
File.open('auth.yaml', 'w') {|f| YAML.dump(auth, f)}
|
41
|
+
|
42
|
+
puts "Done. Have a look at auth.yaml to see what's there."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magento_rest_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4
|
4
|
+
version: 0.1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel.van.den.Oord
|
@@ -46,6 +46,7 @@ executables: []
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- ".gitignore"
|
49
50
|
- ".rspec"
|
50
51
|
- ".travis.yml"
|
51
52
|
- CODE_OF_CONDUCT.md
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- LICENSE.txt
|
55
56
|
- README.md
|
56
57
|
- Rakefile
|
58
|
+
- bin/authenticate
|
57
59
|
- bin/console
|
58
60
|
- bin/setup
|
59
61
|
- lib/magento_rest_api.rb
|