001/* 002 * Copyright 2010-2014 Ning, Inc. 003 * Copyright 2014-2015 The Billing Project, LLC 004 * 005 * The Billing Project licenses this file to you under the Apache License, version 2.0 006 * (the "License"); you may not use this file except in compliance with the 007 * License. You may obtain a copy of the License at: 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 014 * License for the specific language governing permissions and limitations 015 * under the License. 016 */ 017package com.ning.billing.recurly.model; 018 019import com.ning.http.client.Response; 020 021public class ResponseMetadata { 022 /** 023 * Represents the unique id given to this 024 * request by Recurly. Comes from the X-Request-Id 025 * header in the response. 026 */ 027 private String requestId; 028 029 /** 030 * Represents the unique id given to this 031 * request by Cloudflare (if request is proxied through 032 * Cloudflare). Comes from the CF-RAY header in the response. 033 */ 034 private String cfRay; 035 036 /** 037 * The HTTP Status Code of the response. 038 */ 039 private int statusCode; 040 041 public ResponseMetadata(Response response) { 042 this.requestId = response.getHeader("X-Request-Id"); 043 this.cfRay = response.getHeader("CF-RAY"); 044 this.statusCode = response.getStatusCode(); 045 } 046 047 public String getRequestId() { 048 return this.requestId; 049 } 050 051 public String getCfRay() { 052 return this.cfRay; 053 } 054 055 public int getStatusCode() { 056 return this.getStatusCode(); 057 } 058 059 public String toString() { 060 final StringBuilder sb = new StringBuilder("ResponseMetadata{"); 061 sb.append("requestId=").append(requestId); 062 sb.append(", cfRay=").append(cfRay); 063 sb.append(", statusCode=").append(statusCode); 064 sb.append('}'); 065 return sb.toString(); 066 } 067}