Create a pre-defined payload with a badge.

@param badge the badge
@return a ready-to-send payload
182075
public static PushNotificationPayload badge(int badge) {
		PushNotificationPayload payload = complex();
		try {
			payload.addBadge(badge);
		} catch (JSONException e) {
		}
		return payload;
	}
504458
public function preCreate(CreateEvent $event)
    {
        $badge = $event->getObject();

        if ($badge->getWorkspace()) {
            $badge->setEnabled($this->parametersSerializer->serialize()['badges']['enable_default']);
        }
    }
914661
public function getBadgeAction(BadgeClass $badge)
    {
        return new JsonResponse($this->serializer->serialize($badge, [Options::ENFORCE_OPEN_BADGE_JSON]));
    }
1200550
public GitlabBadge getProjectBadge(Serializable projectId, Integer badgeId) throws IOException {
        String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabBadge.URL
                + "/" + badgeId;
        return retrieve().to(tailUrl, GitlabBadge.class);
    }
174697
public static PushNotificationPayload alert(String message) {
		if (message == null) throw new IllegalArgumentException("Alert cannot be null");
		PushNotificationPayload payload = complex();
		try {
			payload.addAlert(message);
		} catch (JSONException e) {
		}
		return payload;
	}
369373
public static Payload create(CharSequence data) {
    return create(StandardCharsets.UTF_8.encode(CharBuffer.wrap(data)), null);
  }
345787
public static PushNotificationPayload combined(String message, int badge, String sound) {
		if (message == null && badge < 0 && sound == null) throw new IllegalArgumentException("Must provide at least one non-null argument");
		PushNotificationPayload payload = complex();
		try {
			if (message != null) payload.addAlert(message);
			if (badge >= 0) payload.addBadge(badge);
			if (sound != null) payload.addSound(sound);
		} catch (JSONException e) {
		}
		return payload;
	}
1098449
public static Payload createPayload(TestRun testRun) {
		if (testRun == null) {
			throw new IllegalArgumentException("The test run must be present.");
		}
		
		Payload payload = new Payload();
		payload.setTestRun(testRun);
		
		return payload;
	}
769651
public static String parseMessagePayload(Element payloadElement) {
        if (payloadElement == null) {
            return "";
        }
        
        try {
            Document payload = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            payload.appendChild(payload.importNode(payloadElement, true));

            String payloadData = XMLUtils.serialize(payload);
            // temporary quickfix for unwanted testcase namespace in target payload
            payloadData = payloadData.replaceAll(" xmlns=\\\"http://www.citrusframework.org/schema/testcase\\\"", "");
            return payloadData.trim();
        } catch (DOMException e) {
            throw new CitrusRuntimeException("Error while constructing message payload", e);
        } catch (ParserConfigurationException e) {
            throw new CitrusRuntimeException("Error while constructing message payload", e);
        }
    }
874446
def add(obj):
    '''
    
    '''
    Form = badge_form(obj.__class__)
    form = api.validate(Form)
    kind = form.kind.data
    badge = obj.get_badge(kind)
    if badge:
        return badge
    else:
        return obj.add_badge(kind), 201
318341
def build_payload(cls, method, args):
        
        ref = str(uuid.uuid4())
        return (method, args, ref)
1033159
public Payment createWithToken( String token ) {
    ValidationUtils.validatesToken( token );

    ParameterMap<String, String> params = new ParameterMap<String, String>();
    params.add( "token", token );

    return RestfulUtils.create( PaymentService.PATH, params, Payment.class, super.httpClient );
  }
1299124
func (p *Payload) Badge(b int) *Payload {
	p.aps().Badge = b
	return p
}
751032
private synchronized void sendPayloadRequest(final PayloadData payload) {
		ApptentiveLog.v(PAYLOADS, "Sending payload: %s", payload);

		// create request object
		final HttpRequest payloadRequest = requestSender.createPayloadSendRequest(payload, new HttpRequest.Listener<HttpRequest>() {
			@Override
			public void onFinish(HttpRequest request) {
				try {
					String json = StringUtils.isNullOrEmpty(request.getResponseData()) ? "{}" : request.getResponseData();
					final JSONObject responseData = new JSONObject(json);
					handleFinishSendingPayload(payload, false, null, request.getResponseCode(), responseData);
				} catch (Exception e) {
					// TODO: Stop assuming the response is JSON. In fact, just send bytes back, and whatever part of the SDK needs it can try to convert it to the desired format.
					ApptentiveLog.e(PAYLOADS, e, "Exception while handling payload send response");
					logException(e);

					handleFinishSendingPayload(payload, false, null, -1, null);
				}
			}

			@Override
			public void onCancel(HttpRequest request) {
				handleFinishSendingPayload(payload, true, null, request.getResponseCode(), null);
			}

			@Override
			public void onFail(HttpRequest request, String reason) {
				if (request.isAuthenticationFailure()) {
					ApptentiveNotificationCenter.defaultCenter().postNotification(NOTIFICATION_AUTHENTICATION_FAILED, NOTIFICATION_KEY_CONVERSATION_ID, payload.getConversationId(), NOTIFICATION_KEY_AUTHENTICATION_FAILED_REASON, request.getAuthenticationFailedReason());
				}
				handleFinishSendingPayload(payload, false, reason, request.getResponseCode(), null);
			}
		});

		// set 'retry' policy
		payloadRequest.setRetryPolicy(requestRetryPolicy);
		payloadRequest.setCallbackQueue(conversationQueue());
		payloadRequest.start();
	}
1291248
public JWTPayload setJwtId(String jwtId) {
        this.jwtId = jwtId;
        this.put(PayloadConstants.JWTID, jwtId);
        return this;
    }
921937
public PayloadType<ConstraintType<T>> getOrCreatePayload()
   {
      Node node = childNode.getOrCreate("payload");
      PayloadType<ConstraintType<T>> payload = new PayloadTypeImpl<ConstraintType<T>>(this, "payload", childNode, node);
      return payload;
   }
756456
static byte[] payloadAndAuthTag(OmemoElement element, byte[] authTag) {
        if (!element.isMessageElement()) {
            throw new IllegalArgumentException("OmemoElement has no payload.");
        }

        byte[] payload = new byte[element.getPayload().length + authTag.length];
        System.arraycopy(element.getPayload(), 0, payload, 0, element.getPayload().length);
        System.arraycopy(authTag, 0, payload, element.getPayload().length, authTag.length);
        return payload;
    }