MCPcopy
hub / github.com/uselotus/lotus / store_token

Method store_token

backend/metering_billing/views/crm_views.py:166–202  ·  view source on GitHub ↗
(self, request, format=None)

Source from the content-addressed store, hash-verified

164 },
165 )
166 def store_token(self, request, format=None):
167 self.check_vessel_token_and_crm_integration(request)
168
169 public_token = request.data["public_token"]
170 response = requests.post(
171 "https://api.vessel.land/link/exchange",
172 headers={
173 "vessel-api-token": VESSEL_API_KEY,
174 "Content-Type": "application/json",
175 },
176 json={"publicToken": public_token},
177 )
178 response = response.json()
179 connection_id = response["connectionId"]
180 access_token = response["accessToken"]
181 native_org_url = response["nativeOrgURL"]
182 native_org_id = response["nativeOrgId"]
183 integration_id = response["integrationId"]
184 crm_provider_value = (
185 UnifiedCRMOrganizationIntegration.get_crm_provider_from_label(
186 integration_id
187 )
188 )
189 if crm_provider_value is None:
190 raise CRMNotSupported(f"CRM type {integration_id} is not supported")
191 conn, _ = UnifiedCRMOrganizationIntegration.objects.update_or_create(
192 organization=request.organization,
193 crm_provider=crm_provider_value,
194 defaults={
195 "access_token": access_token,
196 "native_org_url": native_org_url,
197 "native_org_id": native_org_id,
198 "connection_id": connection_id,
199 },
200 )
201 conn.save()
202 return Response({"success": True}, status=status.HTTP_200_OK)
203
204
205def send_invoice_to_salesforce(invoice, customer, accountId, access_token):

Callers

nothing calls this directly

Calls 5

CRMNotSupportedClass · 0.90
postMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected