yhsd_api 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +5 -0
- data/ChangeLog.md +54 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +242 -0
- data/Rakefile +2 -0
- data/lib/yhsd_api/configuration.rb +48 -0
- data/lib/yhsd_api/exception.rb +41 -0
- data/lib/yhsd_api/helper.rb +78 -0
- data/lib/yhsd_api/http.rb +135 -0
- data/lib/yhsd_api/private_app.rb +114 -0
- data/lib/yhsd_api/public_app.rb +124 -0
- data/lib/yhsd_api/resources/account.rb +25 -0
- data/lib/yhsd_api/resources/asset.rb +37 -0
- data/lib/yhsd_api/resources/base.rb +25 -0
- data/lib/yhsd_api/resources/city.rb +25 -0
- data/lib/yhsd_api/resources/country.rb +25 -0
- data/lib/yhsd_api/resources/customer.rb +43 -0
- data/lib/yhsd_api/resources/customer_address.rb +43 -0
- data/lib/yhsd_api/resources/district.rb +25 -0
- data/lib/yhsd_api/resources/metafield.rb +55 -0
- data/lib/yhsd_api/resources/open_payment.rb +31 -0
- data/lib/yhsd_api/resources/order.rb +31 -0
- data/lib/yhsd_api/resources/page.rb +43 -0
- data/lib/yhsd_api/resources/payment.rb +25 -0
- data/lib/yhsd_api/resources/payment_method.rb +25 -0
- data/lib/yhsd_api/resources/product.rb +43 -0
- data/lib/yhsd_api/resources/product_image.rb +43 -0
- data/lib/yhsd_api/resources/product_variant.rb +43 -0
- data/lib/yhsd_api/resources/province.rb +25 -0
- data/lib/yhsd_api/resources/redirect.rb +43 -0
- data/lib/yhsd_api/resources/script_tag.rb +43 -0
- data/lib/yhsd_api/resources/shipment.rb +37 -0
- data/lib/yhsd_api/resources/shipment_supplier.rb +25 -0
- data/lib/yhsd_api/resources/shop.rb +13 -0
- data/lib/yhsd_api/resources/theme.rb +37 -0
- data/lib/yhsd_api/resources/webhook.rb +45 -0
- data/lib/yhsd_api/resources.rb +2 -0
- data/lib/yhsd_api/version.rb +3 -0
- data/lib/yhsd_api.rb +16 -0
- data/spec/configuration_spec.rb +49 -0
- data/spec/helper_spec.rb +75 -0
- data/spec/private_app_spec.rb +68 -0
- data/spec/public_app_spec.rb +93 -0
- data/spec/resources/account_spec.rb +31 -0
- data/spec/resources/asset_spec.rb +56 -0
- data/spec/resources/city_spec.rb +30 -0
- data/spec/resources/country_spec.rb +28 -0
- data/spec/resources/customer_address_spec.rb +66 -0
- data/spec/resources/customer_spec.rb +67 -0
- data/spec/resources/district_spec.rb +31 -0
- data/spec/resources/metafield_spec.rb +79 -0
- data/spec/resources/open_payment_spec.rb +40 -0
- data/spec/resources/order_spec.rb +41 -0
- data/spec/resources/page_spec.rb +54 -0
- data/spec/resources/payment_method_spec.rb +28 -0
- data/spec/resources/payment_spec.rb +29 -0
- data/spec/resources/product_image_spec.rb +59 -0
- data/spec/resources/product_spec.rb +123 -0
- data/spec/resources/product_variant_spec.rb +74 -0
- data/spec/resources/province_spec.rb +29 -0
- data/spec/resources/redirect_spec.rb +58 -0
- data/spec/resources/script_tag_spec.rb +54 -0
- data/spec/resources/shipment_spec.rb +43 -0
- data/spec/resources/shipment_supplier_spec.rb +31 -0
- data/spec/resources/shop_spec.rb +18 -0
- data/spec/resources/theme_spec.rb +38 -0
- data/spec/resources/webhook_spec.rb +54 -0
- data/spec/spec_helper.rb +9 -0
- data/yhsd_api.gemspec +26 -0
- metadata +217 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::PublicApp do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
YhsdApi.configure do |config|
|
|
7
|
+
config.app_key = '57a7a5aeeb6b4db78f776e3add846e67'
|
|
8
|
+
config.app_secret = 'ca5c91b5ea1f48b78e8bf88ce8d8a6b2'
|
|
9
|
+
config.scope = 'read_basic,
|
|
10
|
+
write_basic '
|
|
11
|
+
end
|
|
12
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
13
|
+
@shop_key = '1bf2910a4df7ec3c211a9f39881716f8'
|
|
14
|
+
@redirect_url = 'https://youhaosuda.com'
|
|
15
|
+
@code = 'cb9b25dff47f40bc95e5244023ef05f9'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "public app get authorize_url" do
|
|
19
|
+
uri = YhsdApi::PublicApp.authorize_url(@redirect_url, @shop_key)
|
|
20
|
+
expect(uri).to be_kind_of(String)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "public app generate token " do
|
|
24
|
+
token = YhsdApi::PublicApp.generate_token(@redirect_url, @code)
|
|
25
|
+
expect(token).to be_kind_of(String)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "public app get" do
|
|
29
|
+
path = "redirects"
|
|
30
|
+
code, body, header = YhsdApi::PublicApp.get(@token, path)
|
|
31
|
+
expect(code).to eq(200)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "public app post" do
|
|
35
|
+
path = "redirects"
|
|
36
|
+
params = {
|
|
37
|
+
"redirect": {
|
|
38
|
+
"path": "/123",
|
|
39
|
+
"target": "/blogs"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
code, body, header = YhsdApi::PublicApp.post(@token, path, params)
|
|
43
|
+
expect([200, 422]).to include(code)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "public app put" do
|
|
47
|
+
path = "redirects/23"
|
|
48
|
+
params = {
|
|
49
|
+
"redirect": {
|
|
50
|
+
"path": "/66",
|
|
51
|
+
"target": "/blogs"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
code, body, header = YhsdApi::PublicApp.put(@token, path, params)
|
|
55
|
+
expect([200, 422]).to include(code)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "public app delete" do
|
|
59
|
+
path = "redirects/23"
|
|
60
|
+
code, body, header = YhsdApi::PublicApp.delete(@token, path)
|
|
61
|
+
expect([200, 422]).to include(code)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
it "symbol verify_hmac must be success" do
|
|
66
|
+
YhsdApi.configure do |config|
|
|
67
|
+
config.app_secret = 'hush'
|
|
68
|
+
end
|
|
69
|
+
params = {
|
|
70
|
+
"shop_key": "a94a110d86d2452eb3e2af4cfb8a3828",
|
|
71
|
+
"code": "a84a110d86d2452eb3e2af4cfb8a3828",
|
|
72
|
+
"account_id": "1",
|
|
73
|
+
"time_stamp": "2013-08-27T13:58:35Z",
|
|
74
|
+
"hmac": "a2a3e2dcd8a82fd9070707d4d921ac4cdc842935bf57bc38c488300ef3960726"
|
|
75
|
+
}
|
|
76
|
+
expect(YhsdApi::PublicApp::verify_hmac(params)).to eq(true)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "string verify_hmac must be success" do
|
|
80
|
+
YhsdApi.configure do |config|
|
|
81
|
+
config.app_secret = 'hush'
|
|
82
|
+
end
|
|
83
|
+
params = {
|
|
84
|
+
"shop_key" => "a94a110d86d2452eb3e2af4cfb8a3828",
|
|
85
|
+
"code" => "a84a110d86d2452eb3e2af4cfb8a3828",
|
|
86
|
+
"account_id" => "1",
|
|
87
|
+
"time_stamp" => "2013-08-27T13:58:35Z",
|
|
88
|
+
"hmac" => "a2a3e2dcd8a82fd9070707d4d921ac4cdc842935bf57bc38c488300ef3960726"
|
|
89
|
+
}
|
|
90
|
+
expect(YhsdApi::PublicApp::verify_hmac(params)).to eq(true)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Account do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 10523
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all account must be success" do
|
|
14
|
+
code, body, header = YhsdApi::Account.all(@token)
|
|
15
|
+
expect(code).to eq(200)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all account count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::Account.count(@token)
|
|
20
|
+
expect(code).to eq(200)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "get single account info must be success" do
|
|
24
|
+
params = {
|
|
25
|
+
"fields" => 'id,name'
|
|
26
|
+
}
|
|
27
|
+
code, body, header = YhsdApi::Account.find(@token, @id, params)
|
|
28
|
+
expect([200, 422]).to include(code)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Asset do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@theme_id = 14130
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all assets info will success" do
|
|
14
|
+
code, body, header = YhsdApi::Asset.all(@token, @theme_id)
|
|
15
|
+
expect(code).to eq(200)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get single theme info will success" do
|
|
19
|
+
params = {
|
|
20
|
+
"asset[key]": "templates/account/change_password.html"
|
|
21
|
+
}
|
|
22
|
+
code, body, header = YhsdApi::Asset.find(@token, @theme_id, params)
|
|
23
|
+
expect(code).to eq(200)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "create theme asset file must be success" do
|
|
27
|
+
params = {
|
|
28
|
+
"asset": {
|
|
29
|
+
"key": "templates/test#{Random.rand(200)}.html",
|
|
30
|
+
"value": "#{Random.rand(200)}"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
code, body, header = YhsdApi::Asset.create(@token, @theme_id, params)
|
|
34
|
+
expect(code).to eq(200)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "update theme asset file must be success" do
|
|
38
|
+
params = {
|
|
39
|
+
"asset": {
|
|
40
|
+
"key": "templates/test139.html",
|
|
41
|
+
"value": "#{Random.rand(200)}"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
code, body, header = YhsdApi::Asset.update(@token, @theme_id, params)
|
|
45
|
+
expect([200, 422]).to include(code)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "delete theme asset file must be success" do
|
|
49
|
+
params = {
|
|
50
|
+
"asset[key]": "templates/teewar.html"
|
|
51
|
+
}
|
|
52
|
+
code, body, header = YhsdApi::Asset.delete(@token, @theme_id, params)
|
|
53
|
+
expect([200, 422]).to include(code)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::City do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@country_id = 1
|
|
11
|
+
@province_id = 10
|
|
12
|
+
@id = 689
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "get all city must be success" do
|
|
16
|
+
code, body, header = YhsdApi::City.all(@token, @country_id, @province_id)
|
|
17
|
+
expect(code).to eq(200)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "get all city count must be success" do
|
|
21
|
+
code, body, header = YhsdApi::City.count(@token, @country_id, @province_id)
|
|
22
|
+
expect(code).to eq(200)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "get single city info" do
|
|
26
|
+
code, body, header = YhsdApi::City.find(@token, @country_id, @province_id, @id)
|
|
27
|
+
expect(code).to eq(200)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Country do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 1
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all country must be success" do
|
|
14
|
+
code, body, header = YhsdApi::Country.all(@token)
|
|
15
|
+
expect(code).to eq(200)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all country count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::Country.count(@token)
|
|
20
|
+
expect(code).to eq(200)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "get single country info" do
|
|
24
|
+
code, body, header = YhsdApi::Country.find(@token, @id)
|
|
25
|
+
expect(code).to eq(200)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::CustomerAddress do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@customer_id = 16902
|
|
11
|
+
@id = 320
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "get all customer address must be success" do
|
|
15
|
+
params = {
|
|
16
|
+
:fields => 'id,completed_address,mobile'
|
|
17
|
+
}
|
|
18
|
+
code, body, header = YhsdApi::CustomerAddress.all(@token, @customer_id, params)
|
|
19
|
+
expect([200, 422]).to include(code)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "get all customer address count must be success" do
|
|
23
|
+
code, body, header = YhsdApi::CustomerAddress.count(@token, @customer_id)
|
|
24
|
+
expect([200, 422]).to include(code)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "get single customer address info must be success" do
|
|
28
|
+
params = {
|
|
29
|
+
:fields => 'id,completed_address,mobile'
|
|
30
|
+
}
|
|
31
|
+
code, body, header = YhsdApi::CustomerAddress.find(@token, @customer_id, @id, params)
|
|
32
|
+
expect([200, 422]).to include(code)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "create a customer must be success" do
|
|
36
|
+
params = {
|
|
37
|
+
"address": {
|
|
38
|
+
"name": "wwww",
|
|
39
|
+
"detail": "wwww",
|
|
40
|
+
"district_code": "110108",
|
|
41
|
+
"mobile": "13265689612"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
code, body, header = YhsdApi::CustomerAddress.create(@token, @customer_id, params)
|
|
45
|
+
expect([200, 422]).to include(code)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "update a customer must be success" do
|
|
49
|
+
params = {
|
|
50
|
+
"address": {
|
|
51
|
+
"name": "wwww",
|
|
52
|
+
"detail": "wwww",
|
|
53
|
+
"district_code": "110108",
|
|
54
|
+
"mobile": "1326568961#{Random.rand(9)}"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
code, body, header = YhsdApi::CustomerAddress.update(@token, @customer_id, @id, params)
|
|
58
|
+
expect([200, 422]).to include(code)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "delete a customer must be success" do
|
|
62
|
+
code, body, header = YhsdApi::CustomerAddress.delete(@token, @customer_id, 321)
|
|
63
|
+
expect([200, 422]).to include(code)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Customer do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 16902
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all customer must be success" do
|
|
14
|
+
params = {
|
|
15
|
+
:fields => 'id,name'
|
|
16
|
+
}
|
|
17
|
+
code, body, header = YhsdApi::Customer.all(@token, params)
|
|
18
|
+
expect([200, 422]).to include(code)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "get all customer count must be success" do
|
|
22
|
+
code, body, header = YhsdApi::Customer.count(@token)
|
|
23
|
+
expect([200, 422]).to include(code)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "get single customer info must be success" do
|
|
27
|
+
params = {
|
|
28
|
+
:fields => 'id,name'
|
|
29
|
+
}
|
|
30
|
+
code, body, header = YhsdApi::Customer.find(@token, @id, params)
|
|
31
|
+
expect([200, 422]).to include(code)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "create a customer must be success" do
|
|
35
|
+
params = {
|
|
36
|
+
"customer": {
|
|
37
|
+
"reg_type":"email",
|
|
38
|
+
"reg_identity": "for#{Random.rand(10000)}@example.com",
|
|
39
|
+
"password":"123456",
|
|
40
|
+
"notify_email":"for@example.com",
|
|
41
|
+
"notify_phone":"13632269380"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
code, body, header = YhsdApi::Customer.create(@token, params)
|
|
45
|
+
expect([200, 422]).to include(code)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "update a customer must be success" do
|
|
49
|
+
params = {
|
|
50
|
+
"customer": {
|
|
51
|
+
"reg_type":"email",
|
|
52
|
+
"reg_identity": "for#{Random.rand(10000)}@example.com",
|
|
53
|
+
"password":"123456",
|
|
54
|
+
"notify_email":"for@example.com",
|
|
55
|
+
"notify_phone":"13632269380"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
code, body, header = YhsdApi::Customer.update(@token, @id, params)
|
|
59
|
+
expect([200, 422]).to include(code)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "delete a customer must be success" do
|
|
63
|
+
code, body, header = YhsdApi::Customer.delete(@token, 243)
|
|
64
|
+
expect([200, 422]).to include(code)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::District do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@country_id = 1
|
|
11
|
+
@province_id = 10
|
|
12
|
+
@city_id = 689
|
|
13
|
+
@id = 689
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "get all district must be success" do
|
|
17
|
+
code, body, header = YhsdApi::District.all(@token, @country_id, @province_id, @city_id)
|
|
18
|
+
expect([200, 422]).to include(code)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "get all district count must be success" do
|
|
22
|
+
code, body, header = YhsdApi::District.count(@token, @country_id, @province_id, @city_id)
|
|
23
|
+
expect([200, 422]).to include(code)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "get single district info" do
|
|
27
|
+
code, body, header = YhsdApi::District.find(@token, @country_id, @province_id, @city_id, @id)
|
|
28
|
+
expect([200, 422]).to include(code)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Metafield do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 448
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all metafield must be success" do
|
|
14
|
+
code, body, header = YhsdApi::Metafield.all(@token)
|
|
15
|
+
expect([200, 422]).to include(code)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all metafield count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::Metafield.count(@token)
|
|
20
|
+
expect([200, 422]).to include(code)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "create a metafield must be success" do
|
|
24
|
+
params = {
|
|
25
|
+
"meta": {
|
|
26
|
+
"name": "shop_score#{Random.rand(10000)}",
|
|
27
|
+
"owner_id": "0",
|
|
28
|
+
"owner_resource": "shop",
|
|
29
|
+
"fields": {
|
|
30
|
+
"key1": "value1",
|
|
31
|
+
"key2": "value2"
|
|
32
|
+
},
|
|
33
|
+
"description": "店铺积分拓展字段"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
code, body, header = YhsdApi::Metafield.create(@token, params)
|
|
37
|
+
expect([200, 422]).to include(code)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "update a metafield must be success" do
|
|
41
|
+
params = {
|
|
42
|
+
"meta": {
|
|
43
|
+
"name": "shop_score",
|
|
44
|
+
"owner_id": "0",
|
|
45
|
+
"owner_resource": "shop",
|
|
46
|
+
"fields": {
|
|
47
|
+
"key1": "value1",
|
|
48
|
+
"key2": "value2"
|
|
49
|
+
},
|
|
50
|
+
"description": "店铺积分拓展字段"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
code, body, header = YhsdApi::Metafield.update(@token, @id, params)
|
|
54
|
+
expect([200, 422]).to include(code)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "delete a metafield must be success" do
|
|
58
|
+
code, body, header = YhsdApi::Metafield.delete(@token, 38)
|
|
59
|
+
expect([200, 422]).to include(code)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "get metafield fields must be success" do
|
|
63
|
+
code, body, header = YhsdApi::Metafield.find_fields(@token, @id)
|
|
64
|
+
expect([200, 422]).to include(code)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "update metafield fields must be success" do
|
|
68
|
+
params = {
|
|
69
|
+
"fields": {
|
|
70
|
+
"key1": "value2",
|
|
71
|
+
"key2": "value3",
|
|
72
|
+
"key3": "value1",
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
code, body, header = YhsdApi::Metafield.update_fields(@token, @id, params)
|
|
76
|
+
expect([200, 422]).to include(code)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::OpenPayment do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 12
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all open payment must be success" do
|
|
14
|
+
code, body, header = YhsdApi::OpenPayment.all(@token)
|
|
15
|
+
expect([200, 422]).to include(code)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all open payment count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::OpenPayment.count(@token)
|
|
20
|
+
expect([200, 422]).to include(code)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "get single open payment info must be success" do
|
|
24
|
+
code, body, header = YhsdApi::OpenPayment.find(@token, @id)
|
|
25
|
+
expect([200, 422]).to include(code)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "create a open payment must be success" do
|
|
29
|
+
params = {
|
|
30
|
+
"open_payment": {
|
|
31
|
+
"trade_no": "TESTAAAAAA#{Random.rand(2000)}",
|
|
32
|
+
"notify_url": "http://www.example.com/test/open_payment_notify_online",
|
|
33
|
+
"amount": 0.01
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
code, body, header = YhsdApi::OpenPayment.create(@token, params)
|
|
37
|
+
expect([200, 422]).to include(code)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Order do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 778
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all order must be success" do
|
|
14
|
+
params = {
|
|
15
|
+
"fields" => "id"
|
|
16
|
+
}
|
|
17
|
+
code, body, header = YhsdApi::Order.all(@token, params)
|
|
18
|
+
expect([200, 422]).to include(code)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "get all order count must be success" do
|
|
22
|
+
code, body, header = YhsdApi::Order.count(@token)
|
|
23
|
+
expect([200, 422]).to include(code)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "get single order must be success" do
|
|
27
|
+
code, body, header = YhsdApi::Order.find(@token, @id)
|
|
28
|
+
expect([200, 422]).to include(code)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "update order info must be success" do
|
|
32
|
+
params = {
|
|
33
|
+
"order": {
|
|
34
|
+
"total_amount": 63.8
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
code, body, header = YhsdApi::Order.update(@token, @id, params)
|
|
38
|
+
expect([200, 422]).to include(code)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Page do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 11300
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all page must be success" do
|
|
14
|
+
code, body, header = YhsdApi::Page.all(@token)
|
|
15
|
+
expect([200, 422]).to include(code)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all page count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::Page.count(@token)
|
|
20
|
+
expect([200, 422]).to include(code)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "get single page info must be success" do
|
|
24
|
+
code, body, header = YhsdApi::Page.find(@token, @id)
|
|
25
|
+
expect([200, 422]).to include(code)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "create a page must be success" do
|
|
29
|
+
params = {
|
|
30
|
+
"page": {
|
|
31
|
+
"handle": "contact#{Random.rand(2000)}",
|
|
32
|
+
"mobile_template": "page.html",
|
|
33
|
+
"page_description": "",
|
|
34
|
+
"page_title": "联系我们#{Random.rand(2000)}",
|
|
35
|
+
"template": "page.html",
|
|
36
|
+
"title": "联系我们#{Random.rand(2000)}",
|
|
37
|
+
"visibility": true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
code, body, header = YhsdApi::Page.create(@token, params)
|
|
41
|
+
expect([200, 422]).to include(code)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "update a page must be success" do
|
|
45
|
+
params = {
|
|
46
|
+
"page": {
|
|
47
|
+
"title": "联系我们#{Random.rand(2000)}"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
code, body, header = YhsdApi::Page.update(@token, @id, params)
|
|
51
|
+
expect([200, 422]).to include(code)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::PaymentMethod do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@id = 121050
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "get all payment method must be success" do
|
|
14
|
+
code, body, header = YhsdApi::PaymentMethod.all(@token)
|
|
15
|
+
expect([200, 422]).to include(code)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "get all payment method count must be success" do
|
|
19
|
+
code, body, header = YhsdApi::PaymentMethod.count(@token)
|
|
20
|
+
expect([200, 422]).to include(code)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "get single payment method must be success" do
|
|
24
|
+
code, body, header = YhsdApi::PaymentMethod.find(@token, @id)
|
|
25
|
+
expect([200, 422]).to include(code)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YhsdApi::Payment do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
@token = '44e8d8f52062453b8fe7342c618d1aef'
|
|
7
|
+
YhsdApi.configure do |config|
|
|
8
|
+
config.call_limit_protect = true
|
|
9
|
+
end
|
|
10
|
+
@order_id = 778
|
|
11
|
+
@id = 698
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "get all payment must be success" do
|
|
15
|
+
code, body, header = YhsdApi::Payment.all(@token, @order_id)
|
|
16
|
+
expect([200, 422]).to include(code)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "get all payment count must be success" do
|
|
20
|
+
code, body, header = YhsdApi::Payment.count(@token, @order_id)
|
|
21
|
+
expect([200, 422]).to include(code)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "get single payment must be success" do
|
|
25
|
+
code, body, header = YhsdApi::Payment.find(@token, @order_id, @id)
|
|
26
|
+
expect([200, 422]).to include(code)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|