+
+
+
+
+
+
+
+
+
+
+
@@ -93,6 +126,57 @@ export default {
},
},
methods: {
+ async createEnvironmentGist() {
+ await this.$axios
+ .$post(
+ "https://api.github.com/gists",
+ {
+ files: {
+ "hoppscotch-environments.json": {
+ content: this.environmentJson,
+ },
+ },
+ },
+ {
+ headers: {
+ Authorization: `token ${this.$store.state.postwoman.providerInfo.accessToken}`,
+ Accept: "application/vnd.github.v3+json",
+ },
+ }
+ )
+ .then((response) => {
+ this.$toast.success(this.$t("gist_created"), {
+ icon: "done",
+ })
+ window.open(response.html_url)
+ })
+ .catch((error) => {
+ this.$toast.error(this.$t("something_went_wrong"), {
+ icon: "error",
+ })
+ console.log(error)
+ })
+ },
+ async readEnvironmentGist() {
+ let gist = prompt(this.$t("enter_gist_url"))
+ if (!gist) return
+ await this.$axios
+ .$get(`https://api.github.com/gists/${gist.split("/").pop()}`, {
+ headers: {
+ Accept: "application/vnd.github.v3+json",
+ },
+ })
+ .then((response) => {
+ let environments = JSON.parse(Object.values(response.files)[0].content)
+ this.$store.commit("postwoman/replaceEnvironments", environments)
+ this.fileImported()
+ this.syncToFBEnvironments()
+ })
+ .catch((error) => {
+ this.failedImport()
+ console.log(error)
+ })
+ },
hideModal() {
this.$emit("hide-modal")
},