dynamics_crm 0.5.0 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +30 -1
- data/lib/dynamics_crm.rb +2 -0
- data/lib/dynamics_crm/fetch_xml/builder.rb +15 -3
- data/lib/dynamics_crm/fetch_xml/entity.rb +15 -1
- data/lib/dynamics_crm/fetch_xml/link_entity.rb +2 -14
- data/lib/dynamics_crm/metadata/entity_metadata.rb +2 -0
- data/lib/dynamics_crm/metadata/one_to_many_relationship.rb +32 -0
- data/lib/dynamics_crm/metadata/relationship_metadata.rb +48 -0
- data/lib/dynamics_crm/version.rb +1 -1
- data/lib/dynamics_crm/xml/message_parser.rb +2 -0
- data/spec/fixtures/retrieve_entity_relationships_response.xml +839 -0
- data/spec/lib/fetch_xml/builder_spec.rb +20 -4
- data/spec/lib/metadata/entity_metadata_spec.rb +62 -0
- metadata +6 -2
@@ -39,6 +39,22 @@ describe DynamicsCRM::FetchXml::Builder do
|
|
39
39
|
<order attribute="productid" descending="false"/>
|
40
40
|
</entity>
|
41
41
|
</fetch>
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
it "builds a single entity with condition" do
|
46
|
+
entity = subject.entity('opportunity').add_attributes(['name', 'amount', 'ownerid'])
|
47
|
+
entity.add_condition('opportunityid', 'eq', '02dd7344-d04a-e411-a9d3-9cb654950300')
|
48
|
+
expect(subject.to_xml).to eq %Q{<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
|
49
|
+
<entity name="opportunity">
|
50
|
+
<attribute name="name"/>
|
51
|
+
<attribute name="amount"/>
|
52
|
+
<attribute name="ownerid"/>
|
53
|
+
<filter type="and">
|
54
|
+
<condition attribute="opportunityid" operator="eq" value="02dd7344-d04a-e411-a9d3-9cb654950300"/>
|
55
|
+
</filter>
|
56
|
+
</entity>
|
57
|
+
</fetch>
|
42
58
|
}
|
43
59
|
end
|
44
60
|
|
@@ -47,7 +63,7 @@ describe DynamicsCRM::FetchXml::Builder do
|
|
47
63
|
context "link_entity" do
|
48
64
|
it "builds entity with link_entity" do
|
49
65
|
entity = subject.entity('opportunityproduct').add_attributes(opportunity_product_fields).order('productid')
|
50
|
-
entity.link_entity('product', to: 'productid', from: 'productid', :alias => 'prod').add_attributes(product_fields)
|
66
|
+
entity.link_entity('product', to: 'productid', from: 'productid', :alias => 'prod', link_type: 'outer').add_attributes(product_fields)
|
51
67
|
expect(subject.to_xml).to eq %Q{<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
|
52
68
|
<entity name="opportunityproduct">
|
53
69
|
<attribute name="productid"/>
|
@@ -57,7 +73,7 @@ describe DynamicsCRM::FetchXml::Builder do
|
|
57
73
|
<attribute name="extendedamount"/>
|
58
74
|
<attribute name="opportunityproductid"/>
|
59
75
|
<order attribute="productid" descending="false"/>
|
60
|
-
<link-entity name="product" from="productid" to="productid" alias="prod">
|
76
|
+
<link-entity name="product" from="productid" to="productid" alias="prod" link-type="outer">
|
61
77
|
<attribute name="name"/>
|
62
78
|
<attribute name="producttypecode"/>
|
63
79
|
<attribute name="price"/>
|
@@ -85,14 +101,14 @@ describe DynamicsCRM::FetchXml::Builder do
|
|
85
101
|
<attribute name="extendedamount"/>
|
86
102
|
<attribute name="opportunityproductid"/>
|
87
103
|
<order attribute="productid" descending="false"/>
|
88
|
-
<link-entity name="product" from="productid" to="productid" alias="prod">
|
104
|
+
<link-entity name="product" from="productid" to="productid" alias="prod" link-type="inner">
|
89
105
|
<attribute name="name"/>
|
90
106
|
<attribute name="producttypecode"/>
|
91
107
|
<attribute name="price"/>
|
92
108
|
<attribute name="standardcost"/>
|
93
109
|
<attribute name="currentcost"/>
|
94
110
|
</link-entity>
|
95
|
-
<link-entity name="opportunity" from="opportunityid" to="opportunityid" alias="oppty">
|
111
|
+
<link-entity name="opportunity" from="opportunityid" to="opportunityid" alias="oppty" link-type="inner">
|
96
112
|
<filter type="and">
|
97
113
|
<condition attribute="opportunityid" operator="eq" value="02dd7344-d04a-e411-a9d3-9cb654950300"/>
|
98
114
|
</filter>
|
@@ -21,4 +21,66 @@ describe DynamicsCRM::Metadata::EntityMetadata do
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
+
context 'relationships' do
|
25
|
+
subject {
|
26
|
+
doc = REXML::Document.new(fixture("retrieve_entity_relationships_response"))
|
27
|
+
entity = doc.get_elements("//b:KeyValuePairOfstringanyType/c:value").first
|
28
|
+
DynamicsCRM::Metadata::EntityMetadata.new(entity)
|
29
|
+
}
|
30
|
+
|
31
|
+
context "parse attributes and relationships according to their type" do
|
32
|
+
it { subject.MetadataId.should == "30b0cd7e-0081-42e1-9a48-688442277fae" }
|
33
|
+
it { subject.LogicalName.should == "opportunity" }
|
34
|
+
it { subject.ObjectTypeCode.should == "3" }
|
35
|
+
it { subject.OwnershipType.should == "UserOwned" }
|
36
|
+
it { subject.PrimaryIdAttribute.should == "opportunityid" }
|
37
|
+
it { subject.PrimaryNameAttribute.should == "name" }
|
38
|
+
it { expect(subject.one_to_many.size).to eq 7 }
|
39
|
+
it { expect(subject.many_to_many.size).to eq 1 }
|
40
|
+
it { expect(subject.many_to_one.size).to eq 8 }
|
41
|
+
end
|
42
|
+
|
43
|
+
context "many to one metadata" do
|
44
|
+
let(:systemuser) { subject.many_to_one.first }
|
45
|
+
|
46
|
+
it { expect(systemuser.entity.LogicalName).to eq "opportunity" }
|
47
|
+
it { expect(systemuser.ReferencedAttribute).to eq 'systemuserid' }
|
48
|
+
it { expect(systemuser.ReferencedEntity).to eq 'systemuser' }
|
49
|
+
it { expect(systemuser.ReferencingAttribute).to eq 'createdby' }
|
50
|
+
it { expect(systemuser.ReferencingEntity).to eq 'opportunity' }
|
51
|
+
|
52
|
+
it { expect(systemuser.link_entity_fragment(["address1_composite", "address1_city"])).to eq %Q{
|
53
|
+
<link-entity name="systemuser" from="systemuserid" to="createdby" alias="systemuser">
|
54
|
+
<attribute name="address1_composite" />
|
55
|
+
<attribute name="address1_city" />
|
56
|
+
</link-entity>
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
context "one to many metadata" do
|
62
|
+
let(:socialactivity) { subject.one_to_many.first }
|
63
|
+
|
64
|
+
it { expect(socialactivity.entity.LogicalName).to eq "opportunity" }
|
65
|
+
it { expect(socialactivity.ReferencedAttribute).to eq 'opportunityid' }
|
66
|
+
it { expect(socialactivity.ReferencedEntity).to eq 'opportunity' }
|
67
|
+
it { expect(socialactivity.ReferencingAttribute).to eq 'regardingobjectid' }
|
68
|
+
it { expect(socialactivity.ReferencingEntity).to eq 'socialactivity' }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "many to many metadata" do
|
72
|
+
let(:competitors) { subject.many_to_many.first }
|
73
|
+
|
74
|
+
it { expect(competitors.entity.LogicalName).to eq "opportunity" }
|
75
|
+
|
76
|
+
it { expect(competitors.SchemaName).to eq "opportunitycompetitors_association" }
|
77
|
+
it { expect(competitors.Entity1IntersectAttribute).to eq "opportunityid" }
|
78
|
+
it { expect(competitors.Entity1LogicalName).to eq "opportunity" }
|
79
|
+
|
80
|
+
it { expect(competitors.Entity2IntersectAttribute).to eq "competitorid" }
|
81
|
+
it { expect(competitors.Entity2LogicalName).to eq "competitor" }
|
82
|
+
it { expect(competitors.IntersectEntityName).to eq "opportunitycompetitors" }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
24
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamics_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Heth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -149,6 +149,8 @@ files:
|
|
149
149
|
- lib/dynamics_crm/fetch_xml/link_entity.rb
|
150
150
|
- lib/dynamics_crm/metadata/attribute_metadata.rb
|
151
151
|
- lib/dynamics_crm/metadata/entity_metadata.rb
|
152
|
+
- lib/dynamics_crm/metadata/one_to_many_relationship.rb
|
153
|
+
- lib/dynamics_crm/metadata/relationship_metadata.rb
|
152
154
|
- lib/dynamics_crm/metadata/retrieve_all_entities_response.rb
|
153
155
|
- lib/dynamics_crm/metadata/retrieve_attribute_response.rb
|
154
156
|
- lib/dynamics_crm/metadata/retrieve_entity_response.rb
|
@@ -188,6 +190,7 @@ files:
|
|
188
190
|
- spec/fixtures/retrieve_attribute_identifier_response.xml
|
189
191
|
- spec/fixtures/retrieve_attribute_picklist_response.xml
|
190
192
|
- spec/fixtures/retrieve_attribute_response.xml
|
193
|
+
- spec/fixtures/retrieve_entity_relationships_response.xml
|
191
194
|
- spec/fixtures/retrieve_entity_response.xml
|
192
195
|
- spec/fixtures/retrieve_multiple_result.xml
|
193
196
|
- spec/fixtures/sender_fault.xml
|
@@ -252,6 +255,7 @@ test_files:
|
|
252
255
|
- spec/fixtures/retrieve_attribute_identifier_response.xml
|
253
256
|
- spec/fixtures/retrieve_attribute_picklist_response.xml
|
254
257
|
- spec/fixtures/retrieve_attribute_response.xml
|
258
|
+
- spec/fixtures/retrieve_entity_relationships_response.xml
|
255
259
|
- spec/fixtures/retrieve_entity_response.xml
|
256
260
|
- spec/fixtures/retrieve_multiple_result.xml
|
257
261
|
- spec/fixtures/sender_fault.xml
|