|
|
|
@@ -12,7 +12,7 @@ import ( |
|
|
|
//abstract CRUD operation for espoCRM Entity |
|
|
|
|
|
|
|
func crmCreateEntity(entityType string, jsonB []byte) (entity interface{}, err error) { |
|
|
|
url := CRMConfig.BaseURL + "api/v1/" + entityType |
|
|
|
url := CRMConfig.apiURL(entityType) |
|
|
|
jsonStr, err := postRAW(jsonB, url, crmBuildCommonAPIHeader()) |
|
|
|
if err != nil { |
|
|
|
entity, _ = crmRescueDuplicateCreate(err, entityType) |
|
|
|
@@ -22,7 +22,7 @@ func crmCreateEntity(entityType string, jsonB []byte) (entity interface{}, err e |
|
|
|
} |
|
|
|
|
|
|
|
func crmUpdateEntity(entityType string, id string, jsonB []byte) (entity interface{}, err error) { |
|
|
|
url := CRMConfig.BaseURL + "api/v1/" + entityType + "/" + id |
|
|
|
url := CRMConfig.apiEntityURL(entityType, id) |
|
|
|
jsonStr, err := patchRAW(jsonB, url, crmBuildCommonAPIHeader()) |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
@@ -32,7 +32,7 @@ func crmUpdateEntity(entityType string, id string, jsonB []byte) (entity interfa |
|
|
|
} |
|
|
|
|
|
|
|
func crmReplaceEntity(entityType string, id string, jsonB []byte) (entity interface{}, err error) { |
|
|
|
url := CRMConfig.BaseURL + "api/v1/" + entityType + "/" + id |
|
|
|
url := CRMConfig.apiEntityURL(entityType, id) |
|
|
|
jsonStr, err := putRAW(jsonB, url, crmBuildCommonAPIHeader()) |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
@@ -42,7 +42,7 @@ func crmReplaceEntity(entityType string, id string, jsonB []byte) (entity interf |
|
|
|
} |
|
|
|
|
|
|
|
func crmDeleteEntity(entityType string, id string) (deleted bool, err error) { |
|
|
|
url := CRMConfig.BaseURL + "api/v1/" + entityType + "/" + id |
|
|
|
url := CRMConfig.apiEntityURL(entityType, id) |
|
|
|
resp, err := deleteRAW(url, crmBuildCommonAPIHeader()) |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |
|
|
|
@@ -54,7 +54,7 @@ func crmDeleteEntity(entityType string, id string) (deleted bool, err error) { |
|
|
|
|
|
|
|
//give an id, return json |
|
|
|
func crmGetEntity(entityType string, id string) (entity interface{}, err error) { |
|
|
|
url := CRMConfig.BaseURL + "api/v1/" + entityType + "/" + id |
|
|
|
url := CRMConfig.apiEntityURL(entityType, id) |
|
|
|
jsonStr, err := getRAW(url, crmBuildCommonAPIHeader()) |
|
|
|
if err != nil { |
|
|
|
log.Println(err) |