-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update config, stat making discord work again
- Loading branch information
1 parent
b5cc3a3
commit 17aa0b6
Showing
7 changed files
with
157 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/spf13/viper" | ||
) | ||
|
||
func printify_UploadImage(fileName, imageURL string) { | ||
// Create the JSON Request and Response Objects | ||
responseJson := PRINTIFY_ImageUploadResponse{} | ||
requestJson := PRINTIFY_ImageUploadRequest{ | ||
FileName: fileName, | ||
URL: imageURL, | ||
} | ||
|
||
// Marshal the JSON Request Body | ||
requestBody, err := json.Marshal(requestJson) | ||
catchErr(err) | ||
|
||
// Create the HTTP Request | ||
req, err := http.NewRequest("POST", viper.GetString("printify_endpoint")+"/uploads/images.json", bytes.NewBuffer(requestBody)) | ||
catchErr(err) | ||
|
||
// Set the HTTP Request Headers | ||
req.Header.Set("Content-Type", "application/json") | ||
req.Header.Set("Authorization", "Bearer "+PRINTIFY_API_KEY) | ||
|
||
// Verbose Output | ||
if verbose { | ||
trace() | ||
fmt.Println("🗂️ Request JSON:", requestJson) | ||
fmt.Println("🌐 HTTP Request", req) | ||
} | ||
|
||
// Make the HTTP Request | ||
httpMakeRequest(req, &responseJson) | ||
|
||
fmt.Println("📤 Image Uploaded to Printify") | ||
fmt.Println("📁 ID:", responseJson.ID) | ||
fmt.Println("📁 Name:", responseJson.FileName) | ||
fmt.Println("📁 Height:", responseJson.Height) | ||
fmt.Println("📁 Width:", responseJson.Width) | ||
fmt.Println("📁 Size:", responseJson.Size) | ||
fmt.Println("📁 MimeType:", responseJson.MimeType) | ||
fmt.Println("📁 PreviewURL:", responseJson.PreviewURL) | ||
fmt.Println("📁 UploadTime:", responseJson.UploadTime) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cmd | ||
|
||
type PRINTIFY_ImageUploadRequest struct { | ||
FileName string `json:"file_name"` | ||
URL string `json:"url"` | ||
} | ||
|
||
type PRINTIFY_ImageUploadResponse struct { | ||
ID string `json:"id"` | ||
FileName string `json:"file_name"` | ||
Height int `json:"height"` | ||
Width int `json:"width"` | ||
Size int `json:"size"` | ||
MimeType string `json:"mime_type"` | ||
PreviewURL string `json:"preview_url"` | ||
UploadTime string `json:"upload_time"` | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters