Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lib/xpm_ruby/schema/client/add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ module Client
AccountManagerID?: Types::String,
Contacts?: Types::Array.of(
Types::Hash.schema(
Contact: Types::Hash.schema(
Name: Types::String,
IsPrimary?: Types::String,
Salutation?: Types::String,
Addressee?: Types::String,
Phone?: Types::Coercible::String,
Mobile?: Types::Coercible::String,
Email?: Types::String,
Position?: Types::String
).with_key_transform(&:to_sym)
Name: Types::String,
IsPrimary?: Types::String,
Salutation?: Types::String,
Addressee?: Types::String,
Phone?: Types::Coercible::String,
Mobile?: Types::Coercible::String,
Email?: Types::String,
Position?: Types::String
).with_key_transform(&:to_sym)
),
BillingClientID?: Types::Coercible::String,
Expand Down
18 changes: 8 additions & 10 deletions lib/xpm_ruby/schema/client/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ module Client
AccountManagerID?: Types::String,
Contacts?: Types::Array.of(
Types::Hash.schema(
Contact: Types::Hash.schema(
Name: Types::String,
IsPrimary?: Types::String,
Salutation?: Types::String,
Addressee?: Types::String,
Phone?: Types::Coercible::String,
Mobile?: Types::Coercible::String,
Email?: Types::String,
Position?: Types::String
).with_key_transform(&:to_sym)
Name: Types::String,
IsPrimary?: Types::String,
Salutation?: Types::String,
Addressee?: Types::String,
Phone?: Types::Coercible::String,
Mobile?: Types::Coercible::String,
Email?: Types::String,
Position?: Types::String
).with_key_transform(&:to_sym)
),
BillingClientID?: Types::Coercible::String,
Expand Down
4 changes: 2 additions & 2 deletions spec/xpm_ruby/schema/client/add_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Schema
context "with a valid Add schema" do
context "with contacts" do
it "should not raise an error" do
hash = { "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Contact" => { "Name" => "Joe Bloggs" } }] }
hash = { "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Name" => "Joe Bloggs" }] }
expect { Client::Add[hash] }.not_to raise_error
end
end
Expand All @@ -32,7 +32,7 @@ module Schema
end

it "should raise an error on contacts" do
hash = { "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Contact" => { "Email" => "Joe Bloggs" } }] }
hash = { "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Email" => "Joe Bloggs" }] }
expect { Client::Add[hash] }.to raise_error(Dry::Types::SchemaError, /Name is missing in Hash input/)
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/xpm_ruby/schema/client/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Schema
context "with a valid Update schema" do
context "with contacts" do
it "should not raise an error" do
hash = { "ID" => 25655881, "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Contact" => { "Name" => "Joe Bloggs" } }] }
hash = { "ID" => 25655881, "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Name" => "Joe Bloggs" }] }
expect { Client::Update[hash] }.not_to raise_error
end
end
Expand All @@ -32,7 +32,7 @@ module Schema
end

it "should raise an error on contacts" do
hash = { "ID" => 25655881, "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Contact" => { "Email" => "Joe Bloggs" } }] }
hash = { "ID" => 25655881, "Name" => "Joe Bloggs Consulting", "Contacts" => [{ "Email" => "Joe Bloggs" }] }
expect { Client::Update[hash] }.to raise_error(Dry::Types::SchemaError, /Name is missing in Hash input/)
end
end
Expand Down