1
I am integrating the CIELO API into my system, they have two types of API, the sandbox and production.
Each with his own merchantKey
, merchantID
, apiUrl
and apiUrlQuery
I have 4 constants for each environment. My initial idea was to implement the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SiteTeste.APIS.CIELO
{
public class CieloAPI
{
string merchantKey, merchantID, apiUrl, apiUrlQuery;
public CieloAPI(string merchantKey, string merchantID, string apiUrl, string apiUrlQuery)
{
this.merchantKey = merchantKey;
this.merchantID = merchantID;
this.apiUrl = apiUrl;
this.apiUrlQuery = apiUrl;
}
}
}
But whenever I was to instantiate a new class CieloAPI
I’d have to go through the keys, outside that I wouldn’t know what the sandbox and production key would be.
I don’t want everything chewed, but I need a north of which resource to use, abstract class? interface? and etc..
Captures information from a file that will be different in development and production. Probably the
[web|app].config
is the best choice.– Jéf Bueno
You can use a pre-processing directive.
– LP. Gonçalves
Use environment variables or configuration files... you can assign these settings at startup through a static class or do dependency injection
– Leandro Angelo