Skip to content

Commit

Permalink
Merge pull request #42 from Ivanov-Anton/s
Browse files Browse the repository at this point in the history
Align features for DID Group resource
  • Loading branch information
gigorok authored May 26, 2023
2 parents 7f6250f + 908af01 commit 60ccecb
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Breaking Changes
- removed DIDWW::Resource::DidGroup::FEATURE_VOICE => in favor DIDWW::Resource::DidGroup::FEATURE_VOICE_IN and DIDWW::Resource::DidGroup::FEATURE_VOICE_OUT [#42](https://github.com/didww/didww-v3-ruby/pull/42)
- removed DIDWW::Resource::DidGroup::FEATURE_SMS in favor of DIDWW::Resource::DidGroup::FEATURE_SMS_IN and DIDWW::Resource::DidGroup::FEATURE_SMS_OUT [#42](https://github.com/didww/didww-v3-ruby/pull/42)

## [4.0.0]
### Breaking Changes
- /v3/did_groups removed `local_prefix` attribute
Expand Down
19 changes: 12 additions & 7 deletions lib/didww/resource/did_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ module DIDWW
module Resource
class DidGroup < Base
# Possible values for did_group.features array
FEATURE_VOICE = 'voice' .freeze
FEATURE_T38 = 't38' .freeze
FEATURE_SMS = 'sms' .freeze
FEATURE_VOICE_IN = 'voice_in'
FEATURE_VOICE_OUT = 'voice_out'
FEATURE_T38 = 't38'
FEATURE_IN_SMS = 'sms_in'
FEATURE_OUT_SMS = 'sms_out'

FEATURES = {
FEATURE_VOICE => 'Voice' .freeze,
FEATURE_T38 => 'T.38 Fax' .freeze,
FEATURE_SMS => 'SMS' .freeze
}.freeze
FEATURE_VOICE_IN => 'Voice IN',
FEATURE_VOICE_OUT => 'Voice OUT',
FEATURE_T38 => 'T.38 Fax',
FEATURE_IN_SMS => 'SMS IN',
FEATURE_OUT_SMS => 'SMS OUT'
}.freeze

has_one :country, class: Country
has_one :city, class: City
Expand Down
14 changes: 11 additions & 3 deletions spec/didww/resources/did_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
let (:client) { DIDWW::Client }

it 'has FEATURES constant' do
expect(described_class::FEATURES).to include('t38', 'voice', 'sms')
expect(DIDWW::Resource::DidGroup::FEATURES).to match(
hash_including(
'sms_in' => 'SMS IN',
'sms_out' => 'SMS OUT',
't38' => 'T.38 Fax',
'voice_in' => 'Voice IN',
'voice_out' => 'Voice OUT',
)
)
end

describe '#features_human' do
it 'humanizes features array attribute' do
expect(subject.features_human).to eq([])
subject.features = ['t38', 'voice']
expect(subject.features_human).to eq(['T.38 Fax', 'Voice'])
subject.features = %w[t38 voice_in]
expect(subject.features_human).to eq(['T.38 Fax', 'Voice IN'])
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/available_dids/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"prefix": "77",
"local_prefix": "",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/available_dids/id/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"prefix": "77",
"local_prefix": "",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/available_dids/id/get/sample_3/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"allow_additional_channels": true,
"area_name": "Washington",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"local_prefix": "",
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/did_groups/get/sample_1/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"attributes": {
"prefix": "77",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down Expand Up @@ -62,7 +62,7 @@
"attributes": {
"prefix": "3",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"area_name": "Tel Aviv",
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/did_groups/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"attributes": {
"prefix": "77",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down Expand Up @@ -82,7 +82,7 @@
"attributes": {
"prefix": "3",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"area_name": "Tel Aviv",
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/did_groups/id/get/sample_1/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"attributes": {
"prefix": "77",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/did_groups/id/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"attributes": {
"prefix": "77",
"features": [
"voice",
"sms"
"voice_in",
"sms_in"
],
"is_metered": false,
"area_name": "National",
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/did_reservations/id/get/sample_3/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"allow_additional_channels": true,
"area_name": "Washington",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"local_prefix": "",
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/did_reservations/id/get/sample_4/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"allow_additional_channels": true,
"area_name": "Washington",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"local_prefix": "",
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/dids/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"prefix": "720",
"local_prefix": "",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"area_name": "National",
Expand Down Expand Up @@ -179,7 +179,7 @@
"prefix": "11",
"local_prefix": "",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"area_name": "Mobile",
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/dids/id/get/sample_2/200.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"prefix": "721",
"local_prefix": "",
"features": [
"voice"
"voice_in"
],
"is_metered": false,
"area_name": "National",
Expand Down

0 comments on commit 60ccecb

Please sign in to comment.