github.com/Files-com/files-sdk-go/v2@v2.1.2/app.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	lib "github.com/Files-com/files-sdk-go/v2/lib"
     7  )
     8  
     9  type App struct {
    10  	Name                string                 `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"`
    11  	ExtendedDescription string                 `json:"extended_description,omitempty" path:"extended_description,omitempty" url:"extended_description,omitempty"`
    12  	ShortDescription    string                 `json:"short_description,omitempty" path:"short_description,omitempty" url:"short_description,omitempty"`
    13  	DocumentationLinks  map[string]interface{} `json:"documentation_links,omitempty" path:"documentation_links,omitempty" url:"documentation_links,omitempty"`
    14  	IconUrl             string                 `json:"icon_url,omitempty" path:"icon_url,omitempty" url:"icon_url,omitempty"`
    15  	LogoUrl             string                 `json:"logo_url,omitempty" path:"logo_url,omitempty" url:"logo_url,omitempty"`
    16  	ScreenshotListUrls  []string               `json:"screenshot_list_urls,omitempty" path:"screenshot_list_urls,omitempty" url:"screenshot_list_urls,omitempty"`
    17  	LogoThumbnailUrl    string                 `json:"logo_thumbnail_url,omitempty" path:"logo_thumbnail_url,omitempty" url:"logo_thumbnail_url,omitempty"`
    18  	SsoStrategyType     string                 `json:"sso_strategy_type,omitempty" path:"sso_strategy_type,omitempty" url:"sso_strategy_type,omitempty"`
    19  	RemoteServerType    string                 `json:"remote_server_type,omitempty" path:"remote_server_type,omitempty" url:"remote_server_type,omitempty"`
    20  	FolderBehaviorType  string                 `json:"folder_behavior_type,omitempty" path:"folder_behavior_type,omitempty" url:"folder_behavior_type,omitempty"`
    21  	ExternalHomepageUrl string                 `json:"external_homepage_url,omitempty" path:"external_homepage_url,omitempty" url:"external_homepage_url,omitempty"`
    22  	MarketingYoutubeUrl string                 `json:"marketing_youtube_url,omitempty" path:"marketing_youtube_url,omitempty" url:"marketing_youtube_url,omitempty"`
    23  	TutorialYoutubeUrl  string                 `json:"tutorial_youtube_url,omitempty" path:"tutorial_youtube_url,omitempty" url:"tutorial_youtube_url,omitempty"`
    24  	AppType             string                 `json:"app_type,omitempty" path:"app_type,omitempty" url:"app_type,omitempty"`
    25  	Featured            *bool                  `json:"featured,omitempty" path:"featured,omitempty" url:"featured,omitempty"`
    26  }
    27  
    28  // Identifier no path or id
    29  
    30  type AppCollection []App
    31  
    32  type AppListParams struct {
    33  	SortBy       map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"`
    34  	Filter       App                    `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"`
    35  	FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"`
    36  	ListParams
    37  }
    38  
    39  func (a *App) UnmarshalJSON(data []byte) error {
    40  	type app App
    41  	var v app
    42  	if err := json.Unmarshal(data, &v); err != nil {
    43  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    44  	}
    45  
    46  	*a = App(v)
    47  	return nil
    48  }
    49  
    50  func (a *AppCollection) UnmarshalJSON(data []byte) error {
    51  	type apps AppCollection
    52  	var v apps
    53  	if err := json.Unmarshal(data, &v); err != nil {
    54  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    55  	}
    56  
    57  	*a = AppCollection(v)
    58  	return nil
    59  }
    60  
    61  func (a *AppCollection) ToSlice() *[]interface{} {
    62  	ret := make([]interface{}, len(*a))
    63  	for i, v := range *a {
    64  		ret[i] = v
    65  	}
    66  
    67  	return &ret
    68  }