Skip to content

Commit

Permalink
Implementing the ID field for question_groups & questions in survey r…
Browse files Browse the repository at this point in the history
…esource
  • Loading branch information
charliecon committed Jul 22, 2024
1 parent 9cd70cd commit 5188210
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
10 changes: 9 additions & 1 deletion docs/resources/quality_forms_survey.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ Optional:
- `na_enabled` (Boolean) Specifies whether a not applicable answer is enabled. Defaults to `false`.
- `visibility_condition` (Block List, Max: 1) Defines conditions where question would be visible (see [below for nested schema](#nestedblock--question_groups--visibility_condition))

Read-Only:

- `id` (String) The ID of the survey question group.

<a id="nestedblock--question_groups--questions"></a>
### Nested Schema for `question_groups.questions`

Expand All @@ -146,6 +150,10 @@ Optional:
- `type` (String) Valid Values: multipleChoiceQuestion, freeTextQuestion, npsQuestion, readOnlyTextBlockQuestion Defaults to `multipleChoiceQuestion`.
- `visibility_condition` (Block List, Max: 1) Defines conditions where question would be visible (see [below for nested schema](#nestedblock--question_groups--questions--visibility_condition))

Read-Only:

- `id` (String) The ID of the survey question.

<a id="nestedblock--question_groups--questions--answer_options"></a>
### Nested Schema for `question_groups.questions.answer_options`

Expand All @@ -160,7 +168,7 @@ Optional:

Read-Only:

- `id` (String) The ID for the answer option.
- `id` (String) The ID of the survey answer option.

<a id="nestedblock--question_groups--questions--answer_options--assistance_conditions"></a>
### Nested Schema for `question_groups.questions.answer_options.assistance_conditions`
Expand Down
32 changes: 26 additions & 6 deletions genesyscloud/resource_genesyscloud_quality_forms_survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ type SurveyFormQuestionStruct struct {
var (
surveyQuestionGroup = &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Description: "The ID of the survey question group.",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "Name of display question in question group.",
Type: schema.TypeString,
Expand Down Expand Up @@ -83,6 +88,11 @@ var (

surveyQuestion = &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Description: "The ID of the survey question.",
Type: schema.TypeString,
Computed: true,
},
"text": {
Description: "Individual question",
Type: schema.TypeString,
Expand Down Expand Up @@ -153,7 +163,7 @@ var (
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Description: "The ID for the answer option.",
Description: "The ID of the survey answer option.",
Computed: true,
},
"text": {
Expand Down Expand Up @@ -216,10 +226,14 @@ func getAllSurveyForms(_ context.Context, clientConfig *platformclientv2.Configu

func SurveyFormExporter() *resourceExporter.ResourceExporter {
return &resourceExporter.ResourceExporter{
GetResourcesFunc: provider.GetAllWithPooledClient(getAllSurveyForms),
RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references
AllowZeroValues: []string{"question_groups.questions.answer_options.value"},
ExcludedAttributes: []string{"question_groups.questions.answer_options.id"},
GetResourcesFunc: provider.GetAllWithPooledClient(getAllSurveyForms),
RefAttrs: map[string]*resourceExporter.RefAttrSettings{}, // No references
AllowZeroValues: []string{"question_groups.questions.answer_options.value"},
ExcludedAttributes: []string{
"question_groups.id",
"question_groups.questions.id",
"question_groups.questions.answer_options.id",
},
}
}

Expand Down Expand Up @@ -548,10 +562,13 @@ func flattenSurveyQuestionGroups(questionGroups *[]platformclientv2.Surveyquesti
return nil
}

questionGroupList := []interface{}{}
var questionGroupList []interface{}

for _, questionGroup := range *questionGroups {
questionGroupMap := make(map[string]interface{})
if questionGroup.Id != nil {
questionGroupMap["id"] = *questionGroup.Id
}
if questionGroup.Name != nil {
questionGroupMap["name"] = *questionGroup.Name
}
Expand Down Expand Up @@ -579,6 +596,9 @@ func flattenSurveyQuestions(questions *[]platformclientv2.Surveyquestion) []inte

for _, question := range *questions {
questionMap := make(map[string]interface{})
if question.Id != nil {
questionMap["id"] = *question.Id
}
if question.Text != nil {
questionMap["text"] = *question.Text
}
Expand Down

0 comments on commit 5188210

Please sign in to comment.