Inheritance: Restify.OAuthTicket
 public static F1OAuthTicket Authorize(F1OAuthTicket ticket, string username, string password, LoginType loginType, bool isStaging = false, bool useDemo = false)
 {
     Client client = new Client(ticket);
     var authUrl = isStaging ? string.Format("https://{0}.staging.fellowshiponeapi.com/", ticket.ChurchCode) : string.Format("https://{0}.fellowshiponeapi.com/", ticket.ChurchCode);
     authUrl += "v1/" + loginType.ToString() + "/AccessToken";
     return BuildTicket(ticket, username, password, client, authUrl);
 }
        public RestClient(F1OAuthTicket ticket, bool isStaging = false, bool useDemo = false)
            : base(ticket)
        {
            var baseUrl = isStaging ? string.Format("https://{0}.staging.fellowshiponeapi.com/", ticket.ChurchCode) : string.Format("https://{0}.fellowshiponeapi.com/", ticket.ChurchCode);

            SetProperties(ticket, useDemo, baseUrl);
        }
 public static F1OAuthTicket ExchangeRequestToken(F1OAuthTicket ticket, bool isStaging = false, bool useDemo = false)
 {
     Client client = new Client(ticket);
     var authUrl = isStaging ? string.Format("https://{0}.staging.fellowshiponeapi.com/", ticket.ChurchCode) : string.Format("https://{0}.fellowshiponeapi.com/", ticket.ChurchCode);
     //var authUrl = string.Format("http://{0}.fellowshiponeapi.local/", ticket.ChurchCode);
     authUrl += "v1/Tokens/AccessToken";
     return BuildTicket(ticket, authUrl);
 }
        public static F1OAuthTicket GetRequestToken(F1OAuthTicket ticket, bool isStaging = false, bool useDemo = false)
        {
            Client client = new Client(ticket);
            var requestTokenUrl = isStaging ? string.Format("https://{0}.staging.fellowshiponeapi.com/", ticket.ChurchCode) : string.Format("https://{0}.fellowshiponeapi.com/", ticket.ChurchCode);
            //var requestTokenUrl = string.Format("http://{0}.fellowshiponeapi.local/", ticket.ChurchCode);
            requestTokenUrl += "v1/RequestToken";

            var oauthTicket = Client.GetRequestToken(ticket, "myapp.com", requestTokenUrl);
            ticket.AccessToken = oauthTicket.AccessToken;
            ticket.AccessTokenSecret = oauthTicket.AccessTokenSecret;
            return ticket;
        }
 public static F1OAuthTicket Authorize(F1OAuthTicket ticket, string username, string password, LoginType loginType, string baseUrl, bool isSecure = false, bool isStaging = false, bool useDemo = false)
 {
     var client = new Client(ticket);
     var authUrl = string.Format("{0}://{1}.{2}/{3}/{4}/{5}", isSecure == true ? "https" : "http", ticket.ChurchCode, baseUrl, "v1", loginType, "AccessToken");
     return BuildTicket(ticket, username, password, client, authUrl);
 }
 public RestClient(F1OAuthTicket ticket, string baseUrl, bool isSecure = false, bool useDemo = false)
     : base(ticket)
 {
     var url = string.Format("{0}://{1}.{2}/", isSecure == true ? "https" : "http", ticket.ChurchCode, baseUrl);
     SetProperties(ticket, useDemo, url);
 }
 private void SetProperties(F1OAuthTicket ticket, bool useDemo, string baseUrl)
 {
     _ticket = ticket;
     _useDemo = useDemo;
     PeopleRealm = new Realms.Person(ticket, baseUrl);
     GivingRealm = new Realms.Giving(ticket, baseUrl);
 }
        private static F1OAuthTicket BuildTicket(F1OAuthTicket ticket, string authUrl)
        {
            IRestResponse response = Client.ExchangeRequestToken(ticket, authUrl);

            if (response.StatusCode != HttpStatusCode.OK)
                throw new Exception(response.StatusDescription);
            else {
                var qs = HttpUtility.ParseQueryString(response.Content);
                ticket.AccessToken = qs["oauth_token"];
                ticket.AccessTokenSecret = qs["oauth_token_secret"];
                if (response.Headers.SingleOrDefault(x => x.Name == "Content-Location") != null) {
                    ticket.PersonURL = response.Headers.SingleOrDefault(x => x.Name == "Content-Location").Value.ToString();
                }
            }
            return ticket;
        }