gitlab.com/evatix-go/core@v1.3.55/coretaskinfo/newInfoCreator.go (about) 1 package coretaskinfo 2 3 import ( 4 "gitlab.com/evatix-go/core/coredata/corejson" 5 ) 6 7 type newInfoCreator struct { 8 Plain newInfoPlainTextCreator 9 Secure newInfoSecureTextCreator 10 } 11 12 func (it newInfoCreator) Deserialized( 13 rawBytes []byte, 14 ) (parsedInfo *Info, parsingErr error) { 15 emptyInfo := Info{} 16 parsingErr = corejson.Deserialize.UsingBytes( 17 rawBytes, &emptyInfo) 18 19 return emptyInfo.ToPtr(), parsingErr 20 } 21 22 func (it newInfoCreator) DeserializedUsingJsonResult( 23 jsonResult *corejson.Result, 24 ) (parsedInfo *Info, parsingErr error) { 25 emptyInfo := Info{} 26 parsingErr = jsonResult.Deserialize( 27 &emptyInfo) 28 29 return emptyInfo.ToPtr(), parsingErr 30 } 31 32 func (it newInfoCreator) Default( 33 name, desc, url string, 34 ) *Info { 35 return &Info{ 36 RootName: name, 37 Description: desc, 38 Url: url, 39 } 40 } 41 42 func (it newInfoCreator) Examples( 43 name, desc, url string, 44 examples ...string, 45 ) *Info { 46 return &Info{ 47 RootName: name, 48 Description: desc, 49 Url: url, 50 Examples: examples, 51 } 52 } 53 54 func (it newInfoCreator) Create( 55 isSecure bool, 56 name, desc, url, 57 hintUrl, errorUrl, 58 exampleUrl, 59 chainingExample string, 60 examples ...string, 61 ) *Info { 62 return &Info{ 63 RootName: name, 64 Description: desc, 65 Url: url, 66 HintUrl: hintUrl, 67 ErrorUrl: errorUrl, 68 ExampleUrl: exampleUrl, 69 SingleExample: chainingExample, 70 Examples: examples, 71 ExcludeOptions: &ExcludingOptions{ 72 IsSecureText: isSecure, 73 }, 74 } 75 } 76 77 func (it newInfoCreator) SecureCreate( 78 name, desc, url, 79 hintUrl, errorUrl, 80 exampleUrl, 81 chainingExample string, 82 examples ...string, 83 ) *Info { 84 return &Info{ 85 RootName: name, 86 Description: desc, 87 Url: url, 88 HintUrl: hintUrl, 89 ErrorUrl: errorUrl, 90 ExampleUrl: exampleUrl, 91 SingleExample: chainingExample, 92 Examples: examples, 93 ExcludeOptions: &ExcludingOptions{ 94 IsSecureText: true, 95 }, 96 } 97 } 98 99 func (it newInfoCreator) PlainCreate( 100 name, desc, url, 101 hintUrl, errorUrl, 102 exampleUrl, 103 chainingExample string, 104 examples ...string, 105 ) *Info { 106 return &Info{ 107 RootName: name, 108 Description: desc, 109 Url: url, 110 HintUrl: hintUrl, 111 ErrorUrl: errorUrl, 112 ExampleUrl: exampleUrl, 113 SingleExample: chainingExample, 114 Examples: examples, 115 } 116 }