Skip to content
Open
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
47 changes: 46 additions & 1 deletion spec/didww/resources/shared_capacity_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,52 @@
expect(shared_capacity_group).to be_persisted
end

xit 'creates a SharedCapacityGroup, assign Dids and include them in response'
it 'creates a SharedCapacityGroup, assign Dids and include them in response' do
stub_didww_request(:post, '/shared_capacity_groups?include=dids').
with(body:
{
"data": {
"type": 'shared_capacity_groups',
"relationships": {
"capacity_pool": {
"data": {
"type": 'capacity_pools',
"id": '71185c2a-fcc7-468b-87e3-85260fbc3b86'
}
},
"dids": {
"data": [
{
"type": 'dids',
"id": 'c208e97e-d3ce-4be6-ba48-ffb459f64ec0'

Check failure on line 220 in spec/didww/resources/shared_capacity_group_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "c208e97e-d3ce-4be6-ba48-ffb459f64ec0" 3 times.

See more on https://sonarcloud.io/project/issues?id=didww_didww-v3-ruby&issues=AZ7FpoA6q26mY3X2crj3&open=AZ7FpoA6q26mY3X2crj3&pullRequest=92
}
]
}
},
"attributes": {
"name": 'Sample Capacity Group',
"shared_channels_count": 3,
"metered_channels_count": 5
}
}
}.to_json).
to_return(
status: 201,
body: api_fixture('shared_capacity_groups/post/create_with_dids_included/201'),
headers: json_api_headers
)

shared_capacity_group = client.shared_capacity_groups.new(name: 'Sample Capacity Group', shared_channels_count: 3, metered_channels_count: 5)
shared_capacity_group.relationships[:capacity_pool] = DIDWW::Resource::CapacityPool.load(id: '71185c2a-fcc7-468b-87e3-85260fbc3b86')
shared_capacity_group.relationships[:dids] = [
DIDWW::Resource::Did.load(id: 'c208e97e-d3ce-4be6-ba48-ffb459f64ec0')
]
shared_capacity_group.request_includes(:dids)
shared_capacity_group.save
expect(shared_capacity_group).to be_persisted
expect(shared_capacity_group.dids).to all(be_kind_of(DIDWW::Resource::Did))
expect(shared_capacity_group.dids.map(&:id)).to contain_exactly('c208e97e-d3ce-4be6-ba48-ffb459f64ec0')
end
end

describe 'with incorrect attributes' do
Expand Down
52 changes: 51 additions & 1 deletion spec/didww/resources/voice_in_trunk_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,57 @@
expect(trunk_group).to be_persisted
end

xit 'creates a TrunkGroup, assign Trunks and include them in response'
it 'creates a TrunkGroup, assign Trunks and include them in response' do
stub_didww_request(:post, '/voice_in_trunk_groups?include=voice_in_trunks').
with(body:
{
"data": {
"type": 'voice_in_trunk_groups',
"relationships": {
"voice_in_trunks": {
"data": [
{
"type": 'voice_in_trunks',
"id": '4380d9a3-0b04-4da3-8383-0fdf43c27fc5'

Check failure on line 193 in spec/didww/resources/voice_in_trunk_group_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "4380d9a3-0b04-4da3-8383-0fdf43c27fc5" 3 times.

See more on https://sonarcloud.io/project/issues?id=didww_didww-v3-ruby&issues=AZ7Fpn-Wq26mY3X2crj0&open=AZ7Fpn-Wq26mY3X2crj0&pullRequest=92
},
{
"type": 'voice_in_trunks',
"id": '82d6875a-d84f-4d18-a47f-d2f470c074fd'

Check failure on line 197 in spec/didww/resources/voice_in_trunk_group_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "82d6875a-d84f-4d18-a47f-d2f470c074fd" 3 times.

See more on https://sonarcloud.io/project/issues?id=didww_didww-v3-ruby&issues=AZ7Fpn-Wq26mY3X2crjz&open=AZ7Fpn-Wq26mY3X2crjz&pullRequest=92
},
{
"type": 'voice_in_trunks',
"id": 'b2baa741-e886-499f-8e43-760c3fdd2924'

Check failure on line 201 in spec/didww/resources/voice_in_trunk_group_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "b2baa741-e886-499f-8e43-760c3fdd2924" 3 times.

See more on https://sonarcloud.io/project/issues?id=didww_didww-v3-ruby&issues=AZ7Fpn-Wq26mY3X2crj1&open=AZ7Fpn-Wq26mY3X2crj1&pullRequest=92
}
]
}
},
"attributes": {
"name": 'Main group',
"capacity_limit": 100
}
}
}.to_json).
to_return(
status: 201,
body: api_fixture('voice_in_trunk_groups/post/create_with_trunks_included/201'),
headers: json_api_headers
)
trunk_group = client.voice_in_trunk_groups.new(name: 'Main group', capacity_limit: 100)
trunk_group.relationships[:voice_in_trunks] = [
DIDWW::Resource::VoiceInTrunk.load(id: '4380d9a3-0b04-4da3-8383-0fdf43c27fc5'),
DIDWW::Resource::VoiceInTrunk.load(id: '82d6875a-d84f-4d18-a47f-d2f470c074fd'),
DIDWW::Resource::VoiceInTrunk.load(id: 'b2baa741-e886-499f-8e43-760c3fdd2924')
]
trunk_group.request_includes(:voice_in_trunks)
trunk_group.save
expect(trunk_group).to be_persisted
expect(trunk_group.voice_in_trunks).to all(be_kind_of(DIDWW::Resource::VoiceInTrunk))
expect(trunk_group.voice_in_trunks.map(&:id)).to contain_exactly(
'4380d9a3-0b04-4da3-8383-0fdf43c27fc5',
'82d6875a-d84f-4d18-a47f-d2f470c074fd',
'b2baa741-e886-499f-8e43-760c3fdd2924'
)
end
end

describe 'when creating TrunkGroup with trunks and name already taken' do
Expand Down
111 changes: 109 additions & 2 deletions spec/didww/resources/voice_in_trunk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,80 @@
expect(trunk.pop).to be_kind_of(DIDWW::Resource::Pop)
end

xit 'creates a SIP trunk with assigning to pop and including it to response'
it 'creates a SIP trunk with assigning to pop and including it to response' do
stub_didww_request(:post, '/voice_in_trunks?include=pop').
with(body:
{
"data": {
"type": 'voice_in_trunks',
"relationships": {
"pop": {
"data": {
"type": 'pops',
"id": 'b4d3ec87-8b2b-4e91-bcda-da67db8a76ca'

Check failure on line 526 in spec/didww/resources/voice_in_trunk_spec.rb

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "b4d3ec87-8b2b-4e91-bcda-da67db8a76ca" 6 times.

See more on https://sonarcloud.io/project/issues?id=didww_didww-v3-ruby&issues=AZ7FpoAqq26mY3X2crj2&open=AZ7FpoAqq26mY3X2crj2&pullRequest=92
}
}
},
"attributes": {
"name": 'Office SIP',
"capacity_limit": 18,
"cli_format": 'e164',
"cli_prefix": '+1',
"configuration": {
"type": 'sip_configurations',
"attributes": base_sip_config_attributes
}
}
}
}.to_json).
to_return(
status: 201,
body: api_fixture('voice_in_trunks/post/create_sip_trunk_with_pop_included/201'),
headers: json_api_headers
)
trunk = client.voice_in_trunks.new(
name: 'Office SIP',
capacity_limit: 18,
cli_format: 'e164',
cli_prefix: '+1',
)
trunk.configuration = DIDWW::ComplexObject::SipConfiguration.new.tap do |c|
c.username = 'username'
c.host = 'example.com'
c.codec_ids = [ 9, 7 ]
c.rx_dtmf_format_id = 1
c.tx_dtmf_format_id = 1
c.resolve_ruri = 'true'
c.auth_enabled = true
c.auth_user = 'username'
c.auth_password = 'password'
c.auth_from_user = 'Office'
c.auth_from_domain = 'example.com'
c.sst_enabled = 'false'
c.sst_min_timer = 600
c.sst_max_timer = 900
c.sst_refresh_method_id = 1
c.sst_accept_501 = 'true'
c.sip_timer_b = 8000
c.dns_srv_failover_timer = 2000
c.rtp_ping = 'false'
c.rtp_timeout = 30
c.force_symmetric_rtp = 'false'
c.symmetric_rtp_ignore_rtcp = 'false'
c.rerouting_disconnect_code_ids = [ 58, 59 ]
c.port = 5060
c.transport_protocol_id = 2
c.max_transfers = 0
c.max_30x_redirects = 0
end
trunk.relationships[:pop] = DIDWW::Resource::Pop.load(id: 'b4d3ec87-8b2b-4e91-bcda-da67db8a76ca')
trunk.request_includes(:pop)
trunk.save
expect(trunk).to be_persisted
expect(trunk.configuration).to be_kind_of(DIDWW::ComplexObject::SipConfiguration)
expect(trunk.pop).to be_kind_of(DIDWW::Resource::Pop)
expect(trunk.pop.id).to eq('b4d3ec87-8b2b-4e91-bcda-da67db8a76ca')
end

end

Expand Down Expand Up @@ -858,7 +931,41 @@
expect(trunk.pop).to be_kind_of(DIDWW::Resource::Pop)
end

xit 'updates a SIP Trunk, with assigning to pop and including it to response'
it 'updates a SIP Trunk, with assigning to pop and including it to response' do
id = '204f6568-a583-40ef-9bef-fff02273b183'
stub_didww_request(:patch, "/voice_in_trunks/#{id}?include=pop").
with(body:
{
"data": {
"id": '204f6568-a583-40ef-9bef-fff02273b183',
"type": 'voice_in_trunks',
"relationships": {
"pop": {
"data": {
"type": 'pops',
"id": 'b4d3ec87-8b2b-4e91-bcda-da67db8a76ca'
}
}
},
"attributes": {
"name": 'New trunk'
}
}
}.to_json).
to_return(
status: 200,
body: api_fixture('voice_in_trunks/post/create_sip_trunk_with_pop_included/201'),
headers: json_api_headers
)
trunk = DIDWW::Resource::VoiceInTrunk.load(id: id)
trunk.name = 'New trunk'
trunk.relationships.pop = DIDWW::Resource::Pop.load(id: 'b4d3ec87-8b2b-4e91-bcda-da67db8a76ca')
trunk.request_includes(:pop)
trunk.save
expect(trunk.errors).to be_empty
expect(trunk.pop).to be_kind_of(DIDWW::Resource::Pop)
expect(trunk.pop.id).to eq('b4d3ec87-8b2b-4e91-bcda-da67db8a76ca')
end

end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"data": {
"id": "e258a0d6-b02f-4d15-913e-fc79e7baeea9",
"type": "shared_capacity_groups",
"attributes": {
"name": "11",
"shared_channels_count": 0,
"created_at": "2018-06-19T11:41:21.644Z",
"metered_channels_count": 0,
"external_reference_id": null
},
"relationships": {
"capacity_pool": {
"links": {
"self": "https://sandbox-api.didww.com/v3/shared_capacity_groups/e258a0d6-b02f-4d15-913e-fc79e7baeea9/relationships/capacity_pool",
"related": "https://sandbox-api.didww.com/v3/shared_capacity_groups/e258a0d6-b02f-4d15-913e-fc79e7baeea9/capacity_pool"
}
},
"dids": {
"links": {
"self": "https://sandbox-api.didww.com/v3/shared_capacity_groups/e258a0d6-b02f-4d15-913e-fc79e7baeea9/relationships/dids",
"related": "https://sandbox-api.didww.com/v3/shared_capacity_groups/e258a0d6-b02f-4d15-913e-fc79e7baeea9/dids"
},
"data": [
{
"type": "dids",
"id": "c208e97e-d3ce-4be6-ba48-ffb459f64ec0"
}
]
}
}
},
"included": [
{
"id": "c208e97e-d3ce-4be6-ba48-ffb459f64ec0",
"type": "dids",
"attributes": {
"blocked": false,
"capacity_limit": 5,
"description": "Hi",
"terminated": false,
"awaiting_registration": false,
"created_at": "2026-04-22T17:46:03.000Z",
"billing_cycles_count": null,
"number": "12015550100",
"expires_at": "2026-06-22T17:47:00.208Z",
"channels_included_count": 0,
"dedicated_channels_count": 1,
"emergency_enabled": false
},
"relationships": {
"did_group": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/did_group",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/did_group"
}
},
"order": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/order",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/order"
}
},
"capacity_pool": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/capacity_pool",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/capacity_pool"
}
},
"shared_capacity_group": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/shared_capacity_group",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/shared_capacity_group"
}
},
"address_verification": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/address_verification",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/address_verification"
}
},
"voice_in_trunk": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/voice_in_trunk",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/voice_in_trunk"
}
},
"voice_in_trunk_group": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/voice_in_trunk_group",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/voice_in_trunk_group"
}
},
"emergency_calling_service": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/emergency_calling_service",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/emergency_calling_service"
}
},
"emergency_verification": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/emergency_verification",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/emergency_verification"
}
},
"identity": {
"links": {
"self": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/relationships/identity",
"related": "https://sandbox-api.didww.com/v3/dids/c208e97e-d3ce-4be6-ba48-ffb459f64ec0/identity"
}
}
}
}
],
"meta": {
"api_version": "2026-04-16"
}
}
Loading
Loading