Skip to content

Commit

Permalink
add type required for group_pickup_feature (2600hz#6042)
Browse files Browse the repository at this point in the history
pass all Data object to cf_group_pickup

process matched var with kz_json:set_values/2

update docs and match var
  • Loading branch information
zzzming authored and jamesaimonetti committed Sep 23, 2019
1 parent 5584805 commit a4ad34e
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 6 deletions.
8 changes: 7 additions & 1 deletion applications/callflow/doc/group_pickup_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ Validator for the group_pickup_feature callflow data object

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`approved_device_id` | Restrict calling device to Device | `string()` | | `false` |
`approved_group_id` | Restrict calling device to Group | `string()` | | `false` |
`approved_user_id` | Restrict calling device to User | `string()` | | `false` |
`device_id` | Device to pickup | `string()` | | `false` |
`group_id` | Group in which to find a call to pickup | `string()` | | `false` |
`skip_module` | When set to true this callflow action is skipped, advancing to the wildcard branch (if any) | `boolean()` | | `false` |
`type` | The type of collection to pickup | `string('group' | 'user' | 'device' | 'extension')` | | `false` |
`type` | The type of collection to pickup | `string('group' | 'user' | 'device' | 'extension')` | | `true` |
`user_id` | User in which to find a call to pickup | `string()` | | `false` |



Expand Down
8 changes: 7 additions & 1 deletion applications/callflow/doc/ref/group_pickup_feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ Validator for the group_pickup_feature callflow data object

Key | Description | Type | Default | Required | Support Level
--- | ----------- | ---- | ------- | -------- | -------------
`approved_device_id` | Restrict calling device to Device | `string()` | | `false` |
`approved_group_id` | Restrict calling device to Group | `string()` | | `false` |
`approved_user_id` | Restrict calling device to User | `string()` | | `false` |
`device_id` | Device to pickup | `string()` | | `false` |
`group_id` | Group in which to find a call to pickup | `string()` | | `false` |
`skip_module` | When set to true this callflow action is skipped, advancing to the wildcard branch (if any) | `boolean()` | | `false` |
`type` | The type of collection to pickup | `string('group' | 'user' | 'device' | 'extension')` | | `false` |
`type` | The type of collection to pickup | `string('group' | 'user' | 'device' | 'extension')` | | `true` |
`user_id` | User in which to find a call to pickup | `string()` | | `false` |



5 changes: 3 additions & 2 deletions applications/callflow/src/module/cf_group_pickup_feature.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ handle(Data, Call) ->
PickupType = kz_json:get_ne_binary_value(<<"type">>, Data),
case build_pickup_params(Number, PickupType, Call) of
{'ok', Params} ->
cf_group_pickup:handle(kz_json:from_list(Params), Call);
UpdatedData = kz_json:set_values(Params, Data),
cf_group_pickup:handle(UpdatedData, Call);
{'error', _E} ->
lager:info("error <<~s>> processing pickup '~s' for number ~s"
,[_E, PickupType, Number]
),
_ = kapps_call_command:b_play(<<"park-no_caller">>, Call),
_ = kapps_call_command:b_prompt(<<"park-no_caller">>, Call),
cf_exe:stop(Call)
end.

Expand Down
27 changes: 27 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,26 @@
"callflows.group_pickup_feature": {
"description": "Validator for the group_pickup_feature callflow data object",
"properties": {
"approved_device_id": {
"description": "Restrict calling device to Device",
"type": "string"
},
"approved_group_id": {
"description": "Restrict calling device to Group",
"type": "string"
},
"approved_user_id": {
"description": "Restrict calling device to User",
"type": "string"
},
"device_id": {
"description": "Device to pickup",
"type": "string"
},
"group_id": {
"description": "Group in which to find a call to pickup",
"type": "string"
},
"skip_module": {
"description": "When set to true this callflow action is skipped, advancing to the wildcard branch (if any)",
"type": "boolean"
Expand All @@ -2570,8 +2590,15 @@
"extension"
],
"type": "string"
},
"user_id": {
"description": "User in which to find a call to pickup",
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"callflows.hangup": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
"_id": "callflows.group_pickup_feature",
"description": "Validator for the group_pickup_feature callflow data object",
"properties": {
"approved_device_id": {
"description": "Restrict calling device to Device",
"type": "string"
},
"approved_group_id": {
"description": "Restrict calling device to Group",
"type": "string"
},
"approved_user_id": {
"description": "Restrict calling device to User",
"type": "string"
},
"device_id": {
"description": "Device to pickup",
"type": "string"
},
"group_id": {
"description": "Group in which to find a call to pickup",
"type": "string"
},
"skip_module": {
"description": "When set to true this callflow action is skipped, advancing to the wildcard branch (if any)",
"type": "boolean"
Expand All @@ -16,7 +36,14 @@
"extension"
],
"type": "string"
},
"user_id": {
"description": "User in which to find a call to pickup",
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
}
20 changes: 20 additions & 0 deletions applications/crossbar/priv/oas3/oas3-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,21 @@
'callflows.group_pickup_feature':
'description': Validator for the group_pickup_feature callflow data object
'properties':
'approved_device_id':
'description': Restrict calling device to Device
'type': string
'approved_group_id':
'description': Restrict calling device to Group
'type': string
'approved_user_id':
'description': Restrict calling device to User
'type': string
'device_id':
'description': Device to pickup
'type': string
'group_id':
'description': Group in which to find a call to pickup
'type': string
'skip_module':
'description': |-
When set to true this callflow action is skipped, advancing to the wildcard branch (if any)
Expand All @@ -2054,6 +2069,11 @@
- device
- extension
'type': string
'user_id':
'description': User in which to find a call to pickup
'type': string
'required':
- type
'type': object
'callflows.hangup':
'description': Validator for the hangup callflow data object
Expand Down
28 changes: 27 additions & 1 deletion core/kazoo_ast/src/cf_data_usage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ process_expression(Acc, ?TUPLE(Elements)) ->
process_expression(Acc, ?CLAUSE(Exprs, _Guards, Body)) ->
process_clause_body(process_expressions(Acc, Exprs), Body);
process_expression(Acc, ?MATCH(Left, Right)) ->
?LOG_DEBUG("process match ~p = ~p~n", [Left, Right]),
process_match(Acc, Left, Right);
process_expression(#usage{current_module=Module}=Acc, ?FUN_ARGS(Function, Args)) ->
process_mfa(Acc, Module, Function, Args);
Expand Down Expand Up @@ -347,6 +348,14 @@ process_match_mfa(#usage{data_var_name=DataName
) ->
?LOG_DEBUG("adding alias ~p~n", [VarName]),
Acc#usage{data_var_aliases=[VarName|Aliases]};
process_match_mfa(#usage{data_var_name=DataName
,data_var_aliases=Aliases
}=Acc
,VarName
,'kz_json', 'set_values', [?VAR(_), ?VAR(DataName)]
) ->
?LOG_DEBUG("adding alias ~p~n", [VarName]),
Acc#usage{data_var_aliases=[VarName|Aliases]};
process_match_mfa(Acc, _VarName, M, F, As) ->
process_mfa(Acc, M, F, As).

Expand All @@ -371,8 +380,22 @@ process_mfa(#usage{data_var_name=DataName
) ->
?LOG_DEBUG("adding set_value usage ~p, ~p, ~p~n", [Key, Value, DataName]),
Acc#usage{usages=maybe_add_usage(Usages, {M, F, arg_to_key(Key), DataName, arg_to_key(Value)})};
process_mfa(#usage{data_var_name=DataName}=Acc
,'kz_json'=_M, 'set_values'=_F, [?VAR(_KVs), ?VAR(DataName)]
) ->
Acc;
process_mfa(#usage{data_var_name=DataName}=Acc
,'kz_json'=M, 'set_values'=_F, [KVs, ?VAR(DataName)=DN]
) ->
?LOG_DEBUG("adding set_values usage ~p: ~p~n", [KVs, DataName]),
lists:foldl(fun({Key, Value}, Usage) ->
process_mfa(Usage, M, 'set_value', [Key, Value, DN])
end
,Acc
,KVs
);
process_mfa(#usage{}=Acc
,'kz_json', _F, [{call, _, _, _}=_Key|_]
,'kz_json', _F, [{'call', _, _, _}=_Key|_]
) ->
Acc;
process_mfa(#usage{data_var_name=DataName
Expand Down Expand Up @@ -722,6 +745,9 @@ process_mfa_clause(#usage{data_var_name=DataName
?MOD_FUN_ARGS('kz_json', 'set_value', _Args)=_ClauseArgs ->
?LOG_DEBUG("skipping set_value on ~p(~p)~n", [_Args, element(2, _ClauseArgs)]),
process_clause_body(Acc, Body);
?MOD_FUN_ARGS('kz_json', 'set_values', _Args)=_ClauseArgs ->
?LOG_DEBUG("skipping set_values on ~p(~p)~n", [_Args, element(2, _ClauseArgs)]),
process_clause_body(Acc, Body);
?VAR(NewName) ->
?LOG_DEBUG(" data name changed from ~p to ~p~n", [DataName, NewName]),
#usage{usages=ClauseUsages
Expand Down
2 changes: 1 addition & 1 deletion core/kazoo_ast/src/kapi_schemas.erl
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ validator_properties({'function', 'has_cost_parameters', 1}) ->
validator_properties({'function', 'store_media_content_v', 1}) ->
kz_json:from_list([{<<"type">>, <<"string">>}]);
validator_properties({'function', _F, _A}) ->
io:format(" no properties for fun ~p/~p~n", [_F, _A]),
?LOG_DEBUG(" no properties for fun ~p/~p~n", [_F, _A]),
kz_json:from_list([{<<"type">>, <<"string">>}]).

cost_parameters_schema() ->
Expand Down

0 comments on commit a4ad34e

Please sign in to comment.