myjohndeere 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7094d45f88b7a1f3a229931b550d6687c5bd406e
4
- data.tar.gz: 935658bdcc9929de086baec3ae083dab1c451afc
3
+ metadata.gz: 1ec3658d0b7ce21176c5545dd633a91674730a81
4
+ data.tar.gz: dad6f610a4dea5360504b30e01bb56b0257a57a7
5
5
  SHA512:
6
- metadata.gz: f93bfd9472e28278ebd2eea785f55500f67c63ccf1578974000052e311b5c060047b42c60324db52029c73344c1b85e3705c4e950fb9ea5e67c82ccf204a1473
7
- data.tar.gz: e813bba2847e0f66a5385a7a8ff13ac636cdfae4f87a8e2a51435071105bf7c110b2e7cbe7068102b1c0c9da7ba20d07ad4435caacaca35035f50a0275d32a2c
6
+ metadata.gz: 0575997ade5455c96d8ffaa879c01501d83b298c3c87a8bbd613454ddbe63822209846ad4dbddef7c40cc2fa70d6cd82c4c271ee325eff6f1d716617144a172d
7
+ data.tar.gz: 0f8737652e4412658cc9d52aaca837bd6be8b6eab95164d84dc9b49120bbb3b6d74a1894e0faef911a9728eb06cfe38c9987561dec8bedb8cf1e2a560f8e0a09
@@ -0,0 +1,32 @@
1
+ module MyJohnDeere
2
+ class ContributionActivation < SingleResource
3
+ self.base_jd_resource = "contributionActivations"
4
+ self.list_resource_path = "organizations/%{organization_id}/#{self.base_jd_resource}"
5
+ self.retrieve_resource_path = self.base_jd_resource
6
+ attributes_to_pull_from_json(:activationStatus, :id)
7
+
8
+ def initialize(json_object, access_token = nil)
9
+ super(json_object, access_token)
10
+ if self.id.nil? then
11
+ self.id = extract_link_with_rel_from_list("self", /contributionActivations\/([^\/]+)\Z/)
12
+ end
13
+ end
14
+
15
+ def self.create(access_token, organization_id, contribution_product_id, activated: true)
16
+ body = {
17
+ # Must include the class
18
+ "@type" => to_s.gsub(/^.*::/, ''),
19
+ activationStatus: activated ? "ACTIVATED" : "DEACTIVATED",
20
+ links: [
21
+ {
22
+ "@type" => "Link",
23
+ rel: "ContributionProduct",
24
+ uri: "#{MyJohnDeere.configuration.endpoint}/contributionProducts/#{contribution_product_id}"
25
+ }
26
+ ]
27
+ }
28
+
29
+ return send_create(access_token, body, organization_id: organization_id)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ module MyJohnDeere
2
+ class ContributionProduct < SingleResource
3
+ self.base_jd_resource = "contributionProducts"
4
+ self.list_resource_path = self.base_jd_resource
5
+ self.retrieve_resource_path = self.base_jd_resource
6
+ attributes_to_pull_from_json(:id, :marketPlaceName, :marketPlaceDescription,
7
+ :marketPlaceLogo, :defaultLocale, :currentStatus, :authenticationCallback,
8
+ :activationCallback, :previewImages, :supportedLocales, :supportedRegions,
9
+ :supportedOperationCenters)
10
+
11
+ def initialize(json_object, access_token = nil)
12
+ super(json_object, access_token)
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module MyJohnDeere
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
data/spec/fixtures.json CHANGED
@@ -1,43 +1,35 @@
1
1
  {
2
2
  "contribution_products" : {
3
- "links":[
4
- {
5
- "rel":"self",
6
- "uri":"https://sandboxapi.deere.com/platform/contributionDefinitions"
7
- }
8
- ],
9
- "total":1,
10
- "values":[
11
- {
12
- "@type":"ContributionDefinition",
13
- "actionDefinitions":[
14
- {
15
- "@type":"ActionDefinition",
16
- "uri":"http://example.com/",
17
- "title":"Title on the Link",
18
- "actionType":"WINDOW",
19
- "displayType":"BUTTON",
20
- "displayLocation":"MAIN_DETAIL",
21
- "masterData":"ORGANIZATION",
22
- "actionIcon":"NO_ICON"
23
- }
24
-
25
- ],
26
- "id":"9da4ae59-37dd-4fb1-a89f-0f906a307da3",
27
- "links":[
3
+ "links": [
4
+ {
5
+ "rel": "self",
6
+ "uri": "https://sandboxapi.deere.com/platform/contributionProducts"
7
+ }
8
+ ],
9
+ "total": 1,
10
+ "values": [
11
+ {
12
+ "@type": "ContributionProduct",
13
+ "marketPlaceName": "PRODUCT_NAME",
14
+ "marketPlaceDescription": "PRODUCT_DESCRITPION",
15
+ "marketPlaceLogo": "https://jd-us01-isg-prod-system.s3.amazonaws.com/b2b/branding/32902911-9f40-41f3-99eb-b0638ed185y7",
16
+ "defaultLocale": "en-us",
17
+ "currentStatus": "APPROVED",
18
+ "id": "32902911-9f40-41f3-99eb-b0638ed185y7",
19
+ "links": [
28
20
  {
29
- "@type":"Link",
30
- "rel":"self",
31
- "uri":"https://sandboxapi.deere.com/platform/contributionDefinitions/9da4ae59-37dd-4fb1-a89f-0f906a307da3"
21
+ "@type": "Link",
22
+ "rel": "self",
23
+ "uri": "https://sandboxapi.deere.com/platform/contributionProducts/32902911-9f40-41f3-99eb-b0638ed185y7"
32
24
  },
33
- {
25
+ {
34
26
  "@type":"Link",
35
- "rel":"contributionProduct",
36
- "uri":"https://sandboxapi.deere.com/platform/contributionProducts/32902911-9f40-41f3-99eb-b0638ed188a9"
37
- }
38
- ]
39
- }
40
- ]
27
+ "rel":"contributionDefinition",
28
+ "uri":" https://sandboxapi.deere.com/platform/contributionProducts/355678a3-e789-48db-9e90-81ae05da114c/contributionDefinitions"
29
+ }
30
+ ]
31
+ }
32
+ ]
41
33
  },
42
34
  "contribution_product" : {
43
35
  "@type": "ContributionProduct",
@@ -0,0 +1,38 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class TestContributionActivation < Minitest::Test
4
+ FIXTURE = API_FIXTURES.fetch("contribution_activation")
5
+ ORGANIZATION_ID = "1234"
6
+ CONTRIBUTION_PRODUCT_ID = "9bd2876a-c423-4a2a-8c25-bff66dde76fe"
7
+ CONTRIBUTION_ACTIVATION_ID = "90d20db5-6bdd-466f-a0ec-17c6271a0a2a"
8
+
9
+ def test_retrieve()
10
+ stub_request(:get, /\/contributionActivations\/#{CONTRIBUTION_ACTIVATION_ID}/).
11
+ to_return(status: 200, body: FIXTURE.to_json)
12
+
13
+ ca = MyJohnDeere::ContributionActivation.retrieve(default_access_token,
14
+ CONTRIBUTION_ACTIVATION_ID)
15
+ assert_equal CONTRIBUTION_ACTIVATION_ID, ca.id
16
+ assert_equal "ACTIVATED", ca.activation_status
17
+ end
18
+
19
+ def test_create
20
+ expected_body = {"@type"=>"ContributionActivation",
21
+ "activationStatus"=>"ACTIVATED",
22
+ "links"=>
23
+ [{"@type"=>"Link",
24
+ "rel"=>"ContributionProduct",
25
+ "uri"=>
26
+ "https://sandboxapi.deere.com/platform/contributionProducts/#{CONTRIBUTION_PRODUCT_ID}"}]}.to_json()
27
+ stub_request(:post, /contributionActivations/).
28
+ with(body: expected_body,
29
+ headers: {'Accept'=>'application/vnd.deere.axiom.v3+json', 'Content-Length'=>expected_body.length, 'Content-Type'=>'application/vnd.deere.axiom.v3+json'}).
30
+ to_return(status: 201, headers: {"Location"=>"https://sandboxapi.deere.com/platform/contributionActivations/#{CONTRIBUTION_ACTIVATION_ID}"})
31
+ response = MyJohnDeere::ContributionActivation.create(default_access_token,
32
+ ORGANIZATION_ID,
33
+ CONTRIBUTION_PRODUCT_ID,
34
+ activated: true
35
+ )
36
+ assert_equal CONTRIBUTION_ACTIVATION_ID, response.id
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path('../test_helper', __FILE__)
2
+
3
+ class TestContributionProduct < Minitest::Test
4
+ FIXTURE = API_FIXTURES.fetch("contribution_product")
5
+ CONTRIBUTION_PRODUCT_ID = "9bd2876a-c423-4a2a-8c25-bff66dde76fe"
6
+
7
+ def test_retrieve()
8
+ stub_request(:get, /\/contributionProducts\/#{CONTRIBUTION_PRODUCT_ID}/).
9
+ to_return(status: 200, body: FIXTURE.to_json)
10
+
11
+ cp = MyJohnDeere::ContributionProduct.retrieve(default_access_token,
12
+ CONTRIBUTION_PRODUCT_ID)
13
+ assert_equal CONTRIBUTION_PRODUCT_ID, cp.id
14
+ assert_equal "PRODUCT_NAME",
15
+ cp.market_place_name
16
+ assert_equal "PRODUCT_DESCRITPION",
17
+ cp.market_place_description
18
+ assert_equal "https://jd-us01-isg-prod-system.s3.amazonaws.com/b2b/branding/32902911-9f40-41f3-99eb-b0638ed185y7",
19
+ cp.market_place_logo
20
+ assert_equal "en-us",
21
+ cp.default_locale
22
+ assert_equal "APPROVED",
23
+ cp.current_status
24
+ end
25
+
26
+ def test_retrieve()
27
+ stub_request(:get, /\/contributionProducts/).
28
+ to_return(status: 200, body: API_FIXTURES.fetch("contribution_products").to_json)
29
+
30
+ cps = MyJohnDeere::ContributionProduct.list(default_access_token)
31
+ assert_equal 1, cps.data.count
32
+ assert_equal MyJohnDeere::ContributionProduct, cps.data[0].class
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myjohndeere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Susmarski
@@ -42,6 +42,8 @@ files:
42
42
  - lib/myjohndeere/access_token.rb
43
43
  - lib/myjohndeere/api_support_item.rb
44
44
  - lib/myjohndeere/boundary.rb
45
+ - lib/myjohndeere/contribution_activation.rb
46
+ - lib/myjohndeere/contribution_product.rb
45
47
  - lib/myjohndeere/core_ext/string.rb
46
48
  - lib/myjohndeere/errors.rb
47
49
  - lib/myjohndeere/field.rb
@@ -67,6 +69,8 @@ files:
67
69
  - test/api_fixtures.rb
68
70
  - test/test_access_token.rb
69
71
  - test/test_boundary.rb
72
+ - test/test_contribution_activation.rb
73
+ - test/test_contribution_product.rb
70
74
  - test/test_field.rb
71
75
  - test/test_file_resource.rb
72
76
  - test/test_helper.rb
@@ -106,6 +110,8 @@ test_files:
106
110
  - test/api_fixtures.rb
107
111
  - test/test_access_token.rb
108
112
  - test/test_boundary.rb
113
+ - test/test_contribution_activation.rb
114
+ - test/test_contribution_product.rb
109
115
  - test/test_field.rb
110
116
  - test/test_file_resource.rb
111
117
  - test/test_helper.rb