[ISSUE-67901957] implement all endpoints
diff --git a/accessEntity/api.go b/accessEntity/api.go
index 6678d3f..34aebb7 100644
--- a/accessEntity/api.go
+++ b/accessEntity/api.go
@@ -44,6 +44,11 @@
 	IdentifierCompanyName    = "companyname"
 )
 
+const (
+	AppTypeDeveloper = "DEVELOPER"
+	AppTypeCompany   = "COMPANY"
+)
+
 var (
 	Identifiers = map[string]bool{
 		"appid":          true,
@@ -115,57 +120,217 @@
 	services.API().HandleFunc(a.AccessEntityPath+EndpointCompany, a.HandleCompanies).Methods("GET")
 	services.API().HandleFunc(a.AccessEntityPath+EndpointCompanyDeveloper, a.HandleCompanyDevelopers).Methods("GET")
 	services.API().HandleFunc(a.AccessEntityPath+EndpointDeveloper, a.HandleDevelopers).Methods("GET")
-	services.API().HandleFunc(a.AccessEntityPath+EndpointAppCredentials, a.HandleConsumers).Methods("GET")
+	services.API().HandleFunc(a.AccessEntityPath+EndpointAppCredentials, a.HandleAppCredentials).Methods("GET")
 	a.apiInitialized = true
 	log.Debug("API endpoints initialized")
 }
 
 func (a *ApiManager) HandleApps(w http.ResponseWriter, r *http.Request) {
-
-}
-
-func (a *ApiManager) HandleApiProducts(w http.ResponseWriter, r *http.Request) {
-	ids, err := extractIdentifiers(r.URL.Query())
+	ids, org, err := extractIdentifiers(r.URL.Query())
 	if err != nil {
 		common.WriteError(w, err.Error(), INVALID_PARAMETERS, http.StatusBadRequest)
 	}
-	details, errRes := a.getApiProduct(ids)
+	res, errRes := a.getApp(org, ids)
 	if errRes != nil {
 		writeJson(errRes, w, r)
 		return
 	}
+	writeJson(res, w, r)
+}
+
+func (a *ApiManager) HandleApiProducts(w http.ResponseWriter, r *http.Request) {
+	ids, org, err := extractIdentifiers(r.URL.Query())
+	if err != nil {
+		common.WriteError(w, err.Error(), INVALID_PARAMETERS, http.StatusBadRequest)
+	}
+	details, errRes := a.getApiProduct(org, ids)
+	if errRes != nil {
+		w.WriteHeader(errRes.StatusCode)
+		writeJson(errRes, w, r)
+		return
+	}
 	writeJson(details, w, r)
 }
 
 func (a *ApiManager) HandleCompanies(w http.ResponseWriter, r *http.Request) {
-
+	ids, org, err := extractIdentifiers(r.URL.Query())
+	if err != nil {
+		common.WriteError(w, err.Error(), INVALID_PARAMETERS, http.StatusBadRequest)
+	}
+	details, errRes := a.getCompany(org, ids)
+	if errRes != nil {
+		w.WriteHeader(errRes.StatusCode)
+		writeJson(errRes, w, r)
+		return
+	}
+	writeJson(details, w, r)
 }
-func (a *ApiManager) HandleCompanyDevelopers(w http.ResponseWriter, r *http.Request) {
 
+func (a *ApiManager) HandleCompanyDevelopers(w http.ResponseWriter, r *http.Request) {
+	ids, org, err := extractIdentifiers(r.URL.Query())
+	if err != nil {
+		common.WriteError(w, err.Error(), INVALID_PARAMETERS, http.StatusBadRequest)
+	}
+	details, errRes := a.getCompanyDeveloper(org, ids)
+	if errRes != nil {
+		w.WriteHeader(errRes.StatusCode)
+		writeJson(errRes, w, r)
+		return
+	}
+	writeJson(details, w, r)
 }
 func (a *ApiManager) HandleDevelopers(w http.ResponseWriter, r *http.Request) {
-
+	ids, org, err := extractIdentifiers(r.URL.Query())
+	if err != nil {
+		common.WriteError(w, err.Error(), INVALID_PARAMETERS, http.StatusBadRequest)
+	}
+	details, errRes := a.getDeveloper(org, ids)
+	if errRes != nil {
+		w.WriteHeader(errRes.StatusCode)
+		writeJson(errRes, w, r)
+		return
+	}
+	writeJson(details, w, r)
 }
-func (a *ApiManager) HandleConsumers(w http.ResponseWriter, r *http.Request) {
+
+func (a *ApiManager) HandleAppCredentials(w http.ResponseWriter, r *http.Request) {
 
 }
 
-func extractIdentifiers(pars map[string][]string) (map[string]string, error) {
+func extractIdentifiers(pars map[string][]string) (map[string]string, string, error) {
 	m := make(map[string]string)
+	org := ""
+	if orgs := pars["organization"]; len(orgs) > 0 {
+		org = orgs[0]
+	}
 	for k, v := range pars {
 		k = strings.ToLower(k)
 		if Identifiers[k] {
 			if len(v) == 1 {
 				m[k] = v[0]
 			} else {
-				return nil, fmt.Errorf("each identifier must have only 1 value")
+				return nil, org, fmt.Errorf("each identifier must have only 1 value")
 			}
 		}
 	}
-	return m, nil
+	return m, org, nil
 }
 
-func (a *ApiManager) getApiProduct(ids map[string]string) (*ApiProductDetails, *common.ErrorResponse) {
+func (a *ApiManager) getCompanyDeveloper(org string, ids map[string]string) (*CompanyDevelopersSuccessResponse, *common.ErrorResponse) {
+	valid, keyVals := parseIdentifiers(EndpointDeveloper, ids)
+	if !valid {
+		return nil, ErrInvalidPar
+	}
+	priKey, priVal, secKey, secVal := keyVals[0], keyVals[1], keyVals[2], keyVals[3]
+
+	devs, err := a.DbMan.GetCompanyDevelopers(priKey, priVal, secKey, secVal)
+	if err != nil {
+		log.Errorf("getCompanyDeveloper: %v", err)
+		return nil, newDbError(err)
+	}
+
+	if len(devs) == 0 {
+		return &CompanyDevelopersSuccessResponse{
+			CompanyDevelopers: nil,
+			Organization:      org,
+		}, nil
+	}
+
+	var details []*CompanyDeveloperDetails
+	for _, dev := range devs {
+		comName, err := a.DbMan.GetComNameByComId(dev.CompanyId)
+		if err != nil {
+			log.Errorf("getCompanyDeveloper: %v", err)
+			return nil, newDbError(err)
+		}
+		email, err := a.DbMan.GetDevEmailByDevId(dev.DeveloperId)
+		if err != nil {
+			log.Errorf("getCompanyDeveloper: %v", err)
+			return nil, newDbError(err)
+		}
+		detail := makeComDevDetails(&dev, comName, email, priKey, priVal)
+		details = append(details, detail)
+	}
+	return &CompanyDevelopersSuccessResponse{
+		CompanyDevelopers: details,
+		Organization:      org,
+	}, nil
+}
+
+func (a *ApiManager) getDeveloper(org string, ids map[string]string) (*DeveloperSuccessResponse, *common.ErrorResponse) {
+	valid, keyVals := parseIdentifiers(EndpointDeveloper, ids)
+	if !valid {
+		return nil, ErrInvalidPar
+	}
+	priKey, priVal, secKey, secVal := keyVals[0], keyVals[1], keyVals[2], keyVals[3]
+
+	devs, err := a.DbMan.GetDevelopers(priKey, priVal, secKey, secVal)
+	if err != nil {
+		log.Errorf("getApiProduct: %v", err)
+		return nil, newDbError(err)
+	}
+
+	if len(devs) == 0 {
+		return &DeveloperSuccessResponse{
+			Developer:    nil,
+			Organization: org,
+		}, nil
+	}
+	dev := &devs[0]
+
+	attrs := a.DbMan.GetKmsAttributes(dev.TenantId, dev.Id)[dev.Id]
+	comNames, err := a.DbMan.GetComNamesByDevId(dev.Id)
+	if err != nil {
+		log.Errorf("getApiProduct: %v", err)
+		return nil, newDbError(err)
+	}
+	appNames, err := a.DbMan.GetAppNamesByDevId(dev.Id)
+	if err != nil {
+		log.Errorf("getApiProduct: %v", err)
+		return nil, newDbError(err)
+	}
+	details := makeDevDetails(dev, appNames, comNames, attrs, priKey, priVal)
+	return &DeveloperSuccessResponse{
+		Developer:    details,
+		Organization: org,
+	}, nil
+}
+
+func (a *ApiManager) getCompany(org string, ids map[string]string) (*CompanySuccessResponse, *common.ErrorResponse) {
+	valid, keyVals := parseIdentifiers(EndpointCompany, ids)
+	if !valid {
+		return nil, ErrInvalidPar
+	}
+	priKey, priVal, secKey, secVal := keyVals[0], keyVals[1], keyVals[2], keyVals[3]
+
+	coms, err := a.DbMan.GetCompanies(priKey, priVal, secKey, secVal)
+	if err != nil {
+		log.Errorf("getApiProduct: %v", err)
+		return nil, newDbError(err)
+	}
+
+	if len(coms) == 0 {
+		return &CompanySuccessResponse{
+			Company:      nil,
+			Organization: org,
+		}, nil
+	}
+	com := &coms[0]
+
+	attrs := a.DbMan.GetKmsAttributes(com.TenantId, com.Id)[com.Id]
+	appNames, err := a.DbMan.GetAppNamesByComId(com.Id)
+	if err != nil {
+		log.Errorf("getApiProduct: %v", err)
+		return nil, newDbError(err)
+	}
+	details := makeCompanyDetails(com, appNames, attrs, priKey, priVal)
+	return &CompanySuccessResponse{
+		Company:      details,
+		Organization: org,
+	}, nil
+}
+
+func (a *ApiManager) getApiProduct(org string, ids map[string]string) (*ApiProductSuccessResponse, *common.ErrorResponse) {
 	valid, keyVals := parseIdentifiers(EndpointApiProduct, ids)
 	if !valid {
 		return nil, ErrInvalidPar
@@ -178,14 +343,163 @@
 		return nil, newDbError(err)
 	}
 
-	var prod *common.ApiProduct
 	var attrs []common.Attribute
-	if len(prods) > 0 {
-		prod = &prods[0]
-		attrs = a.DbMan.GetKmsAttributes(prod.TenantId, prod.Id)[prod.Id]
+	if len(prods) == 0 {
+		return &ApiProductSuccessResponse{
+			ApiProduct:   nil,
+			Organization: org,
+		}, nil
+	}
+	prod := &prods[0]
+	attrs = a.DbMan.GetKmsAttributes(prod.TenantId, prod.Id)[prod.Id]
+	details, errRes := makeApiProductDetails(prod, attrs, priKey, priVal, secKey, secVal)
+	if errRes != nil {
+		return nil, errRes
 	}
 
-	return makeApiProductDetails(prod, attrs, priKey, priVal, secKey, secVal)
+	return &ApiProductSuccessResponse{
+		ApiProduct:   details,
+		Organization: org,
+	}, nil
+}
+
+func (a *ApiManager) getAppCredential(org string, ids map[string]string) (*AppCredentialSuccessResponse, *common.ErrorResponse) {
+	valid, keyVals := parseIdentifiers(EndpointApiProduct, ids)
+	if !valid {
+		return nil, ErrInvalidPar
+	}
+	priKey, priVal, secKey, secVal := keyVals[0], keyVals[1], keyVals[2], keyVals[3]
+
+	appCreds, err := a.DbMan.GetAppCredentials(priKey, priVal, secKey, secVal)
+	if err != nil {
+		log.Errorf("getAppCredential: %v", err)
+		return nil, newDbError(err)
+	}
+
+	if len(appCreds) == 0 {
+		return &AppCredentialSuccessResponse{
+			AppCredential: nil,
+			Organization:  org,
+		}, nil
+	}
+	appCred := &appCreds[0]
+	attrs := a.DbMan.GetKmsAttributes(appCred.TenantId, appCred.Id)[appCred.Id]
+	apps, err := a.DbMan.GetApps(IdentifierAppId, appCred.AppId, "", "")
+	if err != nil {
+		log.Errorf("getAppCredential: %v", err)
+		return nil, newDbError(err)
+	}
+
+	if len(apps) == 0 {
+		log.Errorf("getAppCredential: No App with id=%v", appCred.AppId)
+		return &AppCredentialSuccessResponse{
+			AppCredential: nil,
+			Organization:  org,
+		}, nil
+	}
+	app := &apps[0]
+	cd := a.getCredDetails(appCred, app.Status)
+	devStatus := ""
+	if app.DeveloperId != "" {
+		devStatus, err = a.DbMan.GetStatus(app.DeveloperId, AppTypeDeveloper)
+		if err != nil {
+			log.Errorf("getAppCredential error get status: %v", err)
+			return nil, newDbError(err)
+		}
+	}
+	//TODO: isValidKey
+	cks := makeConsumerKeyStatusDetails(app, cd, devStatus, "")
+	//TODO: redirectUris
+	details := makeAppCredentialDetails(appCred, cks, []string{}, attrs, priKey, priVal)
+	return &AppCredentialSuccessResponse{
+		AppCredential: details,
+		Organization:  org,
+	}, nil
+}
+
+func (a *ApiManager) getApp(org string, ids map[string]string) (*AppSuccessResponse, *common.ErrorResponse) {
+	valid, keyVals := parseIdentifiers(EndpointApp, ids)
+	if !valid {
+		return nil, ErrInvalidPar
+	}
+	priKey, priVal, secKey, secVal := keyVals[0], keyVals[1], keyVals[2], keyVals[3]
+
+	apps, err := a.DbMan.GetApps(priKey, priVal, secKey, secVal)
+	if err != nil {
+		log.Errorf("getApp: %v", err)
+		return nil, newDbError(err)
+	}
+
+	var app *common.App
+	var attrs []common.Attribute
+
+	if len(apps) == 0 {
+		return &AppSuccessResponse{
+			App:          nil,
+			Organization: org,
+		}, nil
+	}
+
+	app = &apps[0]
+	attrs = a.DbMan.GetKmsAttributes(app.TenantId, app.Id)[app.Id]
+	prods, err := a.DbMan.GetApiProductNamesByAppId(app.Id)
+	if err != nil {
+		log.Errorf("getApp error getting productNames: %v", err)
+		return nil, newDbError(err)
+	}
+	parStatus, err := a.DbMan.GetStatus(app.ParentId, app.Type)
+	if err != nil {
+		log.Errorf("getApp error getting parent status: %v", err)
+		return nil, newDbError(err)
+	}
+	creds, err := a.DbMan.GetAppCredentials(IdentifierAppId, app.Id, "", "")
+	if err != nil {
+		log.Errorf("getApp error getting parent status: %v", err)
+		return nil, newDbError(err)
+	}
+	var credDetails []*CredentialDetails
+	for _, cred := range creds {
+		credDetails = append(credDetails, a.getCredDetails(&cred, app.Status))
+	}
+
+	details, errRes := makeAppDetails(app, parStatus, prods, credDetails, attrs, priKey, priVal, secKey, secVal)
+	if errRes != nil {
+		return nil, errRes
+	}
+	return &AppSuccessResponse{
+		App:          details,
+		Organization: org,
+	}, nil
+}
+
+func makeConsumerKeyStatusDetails(app *common.App, c *CredentialDetails, devStatus, isValidKey string) *ConsumerKeyStatusDetails {
+	return &ConsumerKeyStatusDetails{
+		AppCredential:   c,
+		AppID:           c.AppID,
+		AppName:         app.Name,
+		AppStatus:       app.Status,
+		AppType:         app.Type,
+		DeveloperID:     app.DeveloperId,
+		DeveloperStatus: devStatus,
+		IsValidKey:      isValidKey,
+	}
+}
+
+func makeAppCredentialDetails(ac *common.AppCredential, cks *ConsumerKeyStatusDetails, redirectUrl []string, attrs []common.Attribute, priKey, priVal string) *AppCredentialDetails {
+	return &AppCredentialDetails{
+		AppID:                  ac.AppId,
+		AppName:                cks.AppName,
+		Attributes:             attrs,
+		ConsumerKey:            ac.Id,
+		ConsumerKeyStatus:      cks,
+		ConsumerSecret:         ac.ConsumerSecret,
+		DeveloperID:            cks.DeveloperID,
+		PrimaryIdentifierType:  priKey,
+		PrimaryIdentifierValue: priVal,
+		RedirectUris:           redirectUrl, //TODO
+		Scopes:                 common.JsonToStringArray(ac.Scopes),
+		Status:                 ac.Status,
+	}
 }
 
 func makeApiProductDetails(prod *common.ApiProduct, attrs []common.Attribute, priKey, priVal, secKey, secVal string) (*ApiProductDetails, *common.ErrorResponse) {
@@ -196,37 +510,135 @@
 			return nil, newDataError(err)
 		}
 		a = &ApiProductDetails{
-			APIProxies:     common.JsonToStringArray(prod.Proxies),
-			APIResources:   common.JsonToStringArray(prod.ApiResources),
-			ApprovalType:   prod.ApprovalType,
-			Attributes:     attrs,
-			CreatedAt:      prod.CreatedAt,
-			CreatedBy:      prod.CreatedBy,
-			Description:    prod.Description,
-			DisplayName:    prod.DisplayName,
-			Environments:   common.JsonToStringArray(prod.Environments),
-			ID:             prod.Id,
-			LastModifiedAt: prod.UpdatedAt,
-			LastModifiedBy: prod.UpdatedBy,
-			Name:           prod.Name,
-			QuotaInterval:  prod.QuotaInterval,
-			QuotaLimit:     int64(quotaLimit),
-			QuotaTimeUnit:  prod.QuotaTimeUnit,
-			Scopes:         common.JsonToStringArray(prod.Scopes),
+			ApiProxies:               common.JsonToStringArray(prod.Proxies),
+			ApiResources:             common.JsonToStringArray(prod.ApiResources),
+			ApprovalType:             prod.ApprovalType,
+			Attributes:               attrs,
+			CreatedAt:                prod.CreatedAt,
+			CreatedBy:                prod.CreatedBy,
+			Description:              prod.Description,
+			DisplayName:              prod.DisplayName,
+			Environments:             common.JsonToStringArray(prod.Environments),
+			ID:                       prod.Id,
+			LastModifiedAt:           prod.UpdatedAt,
+			LastModifiedBy:           prod.UpdatedBy,
+			Name:                     prod.Name,
+			QuotaInterval:            prod.QuotaInterval,
+			QuotaLimit:               int64(quotaLimit),
+			QuotaTimeUnit:            prod.QuotaTimeUnit,
+			Scopes:                   common.JsonToStringArray(prod.Scopes),
+			PrimaryIdentifierType:    priKey,
+			PrimaryIdentifierValue:   priVal,
+			SecondaryIdentifierType:  secKey,
+			SecondaryIdentifierValue: secVal,
 		}
 	} else {
 		a = new(ApiProductDetails)
 	}
-
-	setResIdentifiers(a, priKey, priVal, secKey, secVal)
 	return a, nil
 }
 
-func setResIdentifiers(a *ApiProductDetails, priKey, priVal, secKey, secVal string) {
-	a.PrimaryIdentifierType = priKey
-	a.PrimaryIdentifierValue = priVal
-	a.SecondaryIdentifierType = secKey
-	a.SecondaryIdentifierValue = secVal
+func makeAppDetails(app *common.App, parentStatus string, prods []string, creds []*CredentialDetails, attrs []common.Attribute, priKey, priVal, secKey, secVal string) (*AppDetails, *common.ErrorResponse) {
+	var a *AppDetails
+	if app != nil {
+		a = &AppDetails{
+			AccessType:               app.AccessType,
+			ApiProducts:              prods,
+			AppCredentials:           creds,
+			AppFamily:                app.AppFamily,
+			AppParentID:              app.ParentId,
+			AppParentStatus:          parentStatus,
+			AppType:                  app.Type,
+			Attributes:               attrs,
+			CallbackUrl:              app.CallbackUrl,
+			CreatedAt:                app.CreatedAt,
+			CreatedBy:                app.CreatedBy,
+			DisplayName:              app.DisplayName,
+			Id:                       app.Id,
+			KeyExpiresIn:             "", //TODO
+			LastModifiedAt:           app.UpdatedAt,
+			LastModifiedBy:           app.UpdatedBy,
+			Name:                     app.Name,
+			Scopes:                   []string{}, //TODO
+			Status:                   app.Status,
+			PrimaryIdentifierType:    priKey,
+			PrimaryIdentifierValue:   priVal,
+			SecondaryIdentifierType:  secKey,
+			SecondaryIdentifierValue: secVal,
+		}
+	} else {
+		a = new(AppDetails)
+	}
+	return a, nil
+}
+
+func makeCompanyDetails(com *common.Company, appNames []string, attrs []common.Attribute, priKey, priVal string) *CompanyDetails {
+	return &CompanyDetails{
+		Apps:           appNames,
+		Attributes:     attrs,
+		CreatedAt:      com.CreatedAt,
+		CreatedBy:      com.CreatedBy,
+		DisplayName:    com.DisplayName,
+		ID:             com.Id,
+		LastModifiedAt: com.UpdatedAt,
+		LastModifiedBy: com.UpdatedBy,
+		Name:           com.Name,
+		PrimaryIdentifierType:  priKey,
+		PrimaryIdentifierValue: priVal,
+		Status:                 com.Status,
+	}
+}
+
+func makeDevDetails(dev *common.Developer, appNames []string, comNames []string, attrs []common.Attribute, priKey, priVal string) *DeveloperDetails {
+	return &DeveloperDetails{
+		Apps:                   appNames,
+		Attributes:             attrs,
+		Companies:              comNames,
+		CreatedAt:              dev.CreatedAt,
+		CreatedBy:              dev.CreatedBy,
+		Email:                  dev.Email,
+		FirstName:              dev.FirstName,
+		ID:                     dev.Id,
+		LastModifiedAt:         dev.UpdatedAt,
+		LastModifiedBy:         dev.UpdatedBy,
+		LastName:               dev.LastName,
+		Password:               dev.Password,
+		PrimaryIdentifierType:  priKey,
+		PrimaryIdentifierValue: priVal,
+		Status:                 dev.Status,
+		UserName:               dev.UserName,
+	}
+}
+
+func makeComDevDetails(comDev *common.CompanyDeveloper, comName, devEmail, priKey, priVal string) *CompanyDeveloperDetails {
+	return &CompanyDeveloperDetails{
+		CompanyName:            comName,
+		CreatedAt:              comDev.CreatedAt,
+		CreatedBy:              comDev.CreatedBy,
+		DeveloperEmail:         devEmail,
+		LastModifiedAt:         comDev.UpdatedAt,
+		LastModifiedBy:         comDev.UpdatedBy,
+		PrimaryIdentifierType:  priKey,
+		PrimaryIdentifierValue: priVal,
+		Roles: common.JsonToStringArray(comDev.Roles),
+	}
+}
+
+func (a *ApiManager) getCredDetails(cred *common.AppCredential, appStatus string) *CredentialDetails {
+
+	return &CredentialDetails{
+		ApiProductReferences: []string{}, //TODO
+		AppID:                cred.AppId,
+		AppStatus:            appStatus,
+		Attributes:           a.DbMan.GetKmsAttributes(cred.TenantId, cred.Id)[cred.Id],
+		ConsumerKey:          cred.Id,
+		ConsumerSecret:       cred.ConsumerSecret,
+		ExpiresAt:            cred.ExpiresAt,
+		IssuedAt:             cred.IssuedAt,
+		MethodType:           cred.MethodType,
+		Scopes:               common.JsonToStringArray(cred.Scopes),
+		Status:               cred.Status,
+	}
 }
 
 func parseIdentifiers(endpoint string, ids map[string]string) (valid bool, keyVals []string) {
diff --git a/accessEntity/api_response.go b/accessEntity/api_response.go
index 07b3f49..ac8930f 100644
--- a/accessEntity/api_response.go
+++ b/accessEntity/api_response.go
@@ -2,12 +2,54 @@
 
 import "github.com/apid/apidVerifyApiKey/common"
 
+type ApiProductSuccessResponse struct {
+	// api product
+	ApiProduct *ApiProductDetails `json:"apiProduct,omitempty"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
+type AppCredentialSuccessResponse struct {
+	// app credential
+	AppCredential *AppCredentialDetails `json:"appCredential,omitempty"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
+type AppSuccessResponse struct {
+	// app
+	App *AppDetails `json:"app,omitempty"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
+type CompanyDevelopersSuccessResponse struct {
+	// company developers
+	CompanyDevelopers []*CompanyDeveloperDetails `json:"companyDevelopers"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
+type CompanySuccessResponse struct {
+	// company
+	Company *CompanyDetails `json:"company,omitempty"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
+type DeveloperSuccessResponse struct {
+	// developer
+	Developer *DeveloperDetails `json:"developer,omitempty"`
+	// Organization Identifier/Name
+	Organization string `json:"organization,omitempty"`
+}
+
 type ApiProductDetails struct {
 	// api proxies
-	APIProxies []string `json:"apiProxies,omitempty"`
+	ApiProxies []string `json:"apiProxies,omitempty"`
 
 	// api resources
-	APIResources []string `json:"apiResources,omitempty"`
+	ApiResources []string `json:"apiResources,omitempty"`
 
 	// approval type
 	ApprovalType string `json:"approvalType,omitempty"`
@@ -66,3 +108,220 @@
 	// secondary identifier value
 	SecondaryIdentifierValue string `json:"secondaryIdentifierValue,omitempty"`
 }
+
+type AppDetails struct {
+
+	// access type
+	AccessType string `json:"accessType,omitempty"`
+	// api products
+	ApiProducts []string `json:"apiProducts"`
+	// app credentials
+	AppCredentials []*CredentialDetails `json:"appCredentials"`
+	// app family
+	AppFamily string `json:"appFamily,omitempty"`
+	// app parent Id
+	AppParentID string `json:"appParentId,omitempty"`
+	// app parent status
+	AppParentStatus string `json:"appParentStatus,omitempty"`
+	// Developer or Company
+	AppType string `json:"appType,omitempty"`
+	// Attributes associated with the app.
+	Attributes []common.Attribute `json:"attributes"`
+	// callback Url
+	CallbackUrl string `json:"callbackUrl,omitempty"`
+	// ISO-8601
+	CreatedAt string `json:"createdAt,omitempty"`
+	// created by
+	CreatedBy string `json:"createdBy,omitempty"`
+	// display name
+	DisplayName string `json:"displayName,omitempty"`
+	// id
+	Id string `json:"id,omitempty"`
+	// key expires in
+	KeyExpiresIn string `json:"keyExpiresIn,omitempty"`
+	// ISO-8601
+	LastModifiedAt string `json:"lastModifiedAt,omitempty"`
+	// last modified by
+	LastModifiedBy string `json:"lastModifiedBy,omitempty"`
+	// name
+	Name string `json:"name,omitempty"`
+	// primary identifier type
+	PrimaryIdentifierType string `json:"primaryIdentifierType,omitempty"`
+	// primary identifier value
+	PrimaryIdentifierValue string `json:"primaryIdentifierValue,omitempty"`
+	// scopes
+	Scopes []string `json:"scopes"`
+	// secondary identifier type
+	SecondaryIdentifierType string `json:"secondaryIdentifierType,omitempty"`
+	// secondary identifier value
+	SecondaryIdentifierValue string `json:"secondaryIdentifierValue,omitempty"`
+	// status
+	Status string `json:"status,omitempty"`
+}
+
+type CredentialDetails struct {
+	// api product references
+	ApiProductReferences []string `json:"apiProductReferences"`
+	// app Id
+	AppID string `json:"appId,omitempty"`
+	// app status
+	AppStatus string `json:"appStatus,omitempty"`
+	// Attributes associated with the client Id.
+	Attributes []common.Attribute `json:"attributes"`
+	// consumer key
+	ConsumerKey string `json:"consumerKey,omitempty"`
+	// consumer secret
+	ConsumerSecret string `json:"consumerSecret,omitempty"`
+	// expires at
+	ExpiresAt string `json:"expiresAt,omitempty"`
+	// issued at
+	IssuedAt string `json:"issuedAt,omitempty"`
+	// method type
+	MethodType string `json:"methodType,omitempty"`
+	// scopes
+	Scopes []string `json:"scopes"`
+	// status
+	Status string `json:"status,omitempty"`
+}
+
+type AppCredentialDetails struct {
+	// app Id
+	AppID string `json:"appId,omitempty"`
+	// app name
+	AppName string `json:"appName,omitempty"`
+	// Attributes associated with the app credential
+	Attributes []common.Attribute `json:"attributes"`
+	// consumer key
+	ConsumerKey string `json:"consumerKey,omitempty"`
+	// consumer key status
+	ConsumerKeyStatus *ConsumerKeyStatusDetails `json:"consumerKeyStatus,omitempty"`
+	// consumer secret
+	ConsumerSecret string `json:"consumerSecret,omitempty"`
+	// developer Id
+	DeveloperID string `json:"developerId,omitempty"`
+	// primary identifier type
+	PrimaryIdentifierType string `json:"primaryIdentifierType,omitempty"`
+	// primary identifier value
+	PrimaryIdentifierValue string `json:"primaryIdentifierValue,omitempty"`
+	// redirect uris
+	RedirectUris []string `json:"redirectURIs"`
+	// scopes
+	Scopes []string `json:"scopes"`
+	// TODO: no secondary identifier type
+	SecondaryIdentifierType string `json:"secondaryIdentifierType,omitempty"`
+	// TODO: no secondary identifier value
+	SecondaryIdentifierValue string `json:"secondaryIdentifierValue,omitempty"`
+	// status
+	Status string `json:"status,omitempty"`
+}
+
+type ConsumerKeyStatusDetails struct {
+
+	// app credential
+	AppCredential *CredentialDetails `json:"appCredential,omitempty"`
+
+	// app Id
+	AppID string `json:"appId,omitempty"`
+
+	// app name
+	AppName string `json:"appName,omitempty"`
+
+	// app status
+	AppStatus string `json:"appStatus,omitempty"`
+
+	// app type
+	AppType string `json:"appType,omitempty"`
+
+	// developer Id
+	DeveloperID string `json:"developerId,omitempty"`
+
+	// developer status
+	DeveloperStatus string `json:"developerStatus,omitempty"`
+
+	// is valid key
+	IsValidKey string `json:"isValidKey,omitempty"`
+}
+
+type CompanyDetails struct {
+
+	// apps
+	Apps []string `json:"apps"`
+	// Attributes associated with the company.
+	Attributes []common.Attribute `json:"attributes"`
+	// ISO-8601
+	CreatedAt string `json:"createdAt,omitempty"`
+	// created by
+	CreatedBy string `json:"createdBy,omitempty"`
+	// display name
+	DisplayName string `json:"displayName,omitempty"`
+	// id
+	ID string `json:"id,omitempty"`
+	// ISO-8601
+	LastModifiedAt string `json:"lastModifiedAt,omitempty"`
+	// last modified by
+	LastModifiedBy string `json:"lastModifiedBy,omitempty"`
+	// name
+	Name string `json:"name,omitempty"`
+	// primary identifier type
+	PrimaryIdentifierType string `json:"primaryIdentifierType,omitempty"`
+	// primary identifier value
+	PrimaryIdentifierValue string `json:"primaryIdentifierValue,omitempty"`
+	// status
+	Status string `json:"status,omitempty"`
+}
+
+type CompanyDeveloperDetails struct {
+	// company name
+	CompanyName string `json:"companyName,omitempty"`
+	// ISO-8601
+	CreatedAt string `json:"createdAt,omitempty"`
+	// created by
+	CreatedBy string `json:"createdBy,omitempty"`
+	// developer email
+	DeveloperEmail string `json:"developerEmail,omitempty"`
+	// ISO-8601
+	LastModifiedAt string `json:"lastModifiedAt,omitempty"`
+	// last modified by
+	LastModifiedBy string `json:"lastModifiedBy,omitempty"`
+	// primary identifier type
+	PrimaryIdentifierType string `json:"primaryIdentifierType,omitempty"`
+	// primary identifier value
+	PrimaryIdentifierValue string `json:"primaryIdentifierValue,omitempty"`
+	// roles
+	Roles []string `json:"roles"`
+}
+
+type DeveloperDetails struct {
+	// apps
+	Apps []string `json:"apps"`
+	// Attributes associated with the developer.
+	Attributes []common.Attribute `json:"attributes"`
+	// companies
+	Companies []string `json:"companies"`
+	// ISO-8601
+	CreatedAt string `json:"createdAt,omitempty"`
+	// created by
+	CreatedBy string `json:"createdBy,omitempty"`
+	// email
+	Email string `json:"email,omitempty"`
+	// first name
+	FirstName string `json:"firstName,omitempty"`
+	// id
+	ID string `json:"id,omitempty"`
+	// ISO-8601
+	LastModifiedAt string `json:"lastModifiedAt,omitempty"`
+	// last modified by
+	LastModifiedBy string `json:"lastModifiedBy,omitempty"`
+	// last name
+	LastName string `json:"lastName,omitempty"`
+	// password
+	Password string `json:"password,omitempty"`
+	// primary identifier type
+	PrimaryIdentifierType string `json:"primaryIdentifierType,omitempty"`
+	// primary identifier value
+	PrimaryIdentifierValue string `json:"primaryIdentifierValue,omitempty"`
+	// status
+	Status string `json:"status,omitempty"`
+	// user name
+	UserName string `json:"userName,omitempty"`
+}
diff --git a/accessEntity/data.go b/accessEntity/data.go
index dabb2a3..0307c7a 100644
--- a/accessEntity/data.go
+++ b/accessEntity/data.go
@@ -14,26 +14,183 @@
 package accessEntity
 
 import (
+	"database/sql"
 	"github.com/apid/apidVerifyApiKey/common"
 	"strings"
 )
 
 const (
 	sql_select_api_product = `SELECT * FROM kms_api_product AS ap `
-	sql_select_api         = `
-	SELECT * FROM kms_api_product AS ap WHERE ap.id IN (
-		SELECT apiprdt_id FROM kms_app_credential_apiproduct_mapper AS acm WHERE acm.app_id IN (
-			SELECT a.id FROM kms_app AS a WHERE a.name IN ('apstest')
-		)
-	);
-
-	`
+	sql_select_org         = `SELECT * FROM kms_organization AS o WHERE o.tenant_id=$1 LIMIT 1;`
 )
 
 type DbManager struct {
 	common.DbManager
 }
 
+func (d *DbManager) GetOrgName(tenantId string) (string, error) {
+	row := d.GetDb().QueryRow(sql_select_org, tenantId)
+	org := sql.NullString{}
+	if err := row.Scan(&org); err != nil {
+		return "", err
+	}
+	if org.Valid {
+		return org.String, nil
+	}
+	return "", nil
+}
+
+func (d *DbManager) GetApiProductNamesByAppId(appId string) ([]string, error) {
+	query := selectApiProductsById(
+		selectAppCredentialMapperByAppId(
+			"'"+appId+"'",
+			"apiprdt_id",
+		),
+		"name",
+	)
+	rows, err := d.GetDb().Query(query)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var names []string
+	for rows.Next() {
+		name := sql.NullString{}
+		err = rows.Scan(&name)
+		if err != nil {
+			return nil, err
+		}
+		if name.Valid {
+			names = append(names, name.String)
+		}
+	}
+	return names, nil
+}
+
+func (d *DbManager) GetAppNamesByComId(comId string) ([]string, error) {
+	query := selectAppByComId(
+		"'"+comId+"'",
+		"name",
+	)
+	rows, err := d.GetDb().Query(query)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var names []string
+	for rows.Next() {
+		name := sql.NullString{}
+		err = rows.Scan(&name)
+		if err != nil {
+			return nil, err
+		}
+		if name.Valid {
+			names = append(names, name.String)
+		}
+	}
+	return names, nil
+}
+
+func (d *DbManager) GetComNameByComId(comId string) (string, error) {
+	query := selectCompanyByComId(
+		"'"+comId+"'",
+		"name",
+	)
+	name := sql.NullString{}
+	err := d.GetDb().QueryRow(query).Scan(&name)
+	if err != nil || !name.Valid {
+		return "", err
+	}
+	return name.String, nil
+}
+
+func (d *DbManager) GetDevEmailByDevId(devId string) (string, error) {
+	query := selectDeveloperById(
+		"'"+devId+"'",
+		"email",
+	)
+	email := sql.NullString{}
+	err := d.GetDb().QueryRow(query).Scan(&email)
+	if err != nil || !email.Valid {
+		return "", err
+	}
+	return email.String, nil
+}
+
+func (d *DbManager) GetComNamesByDevId(devId string) ([]string, error) {
+	query := selectCompanyByComId(
+		selectCompanyDeveloperByDevId(
+			"'"+devId+"'",
+			"company_id",
+		),
+		"name",
+	)
+	rows, err := d.GetDb().Query(query)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var names []string
+	for rows.Next() {
+		name := sql.NullString{}
+		err = rows.Scan(&name)
+		if err != nil {
+			return nil, err
+		}
+		if name.Valid {
+			names = append(names, name.String)
+		}
+	}
+	return names, nil
+}
+
+func (d *DbManager) GetAppNamesByDevId(devId string) ([]string, error) {
+	query := selectAppByDevId(
+		"'"+devId+"'",
+		"name",
+	)
+	rows, err := d.GetDb().Query(query)
+	if err != nil {
+		return nil, err
+	}
+	defer rows.Close()
+	var names []string
+	for rows.Next() {
+		name := sql.NullString{}
+		err = rows.Scan(&name)
+		if err != nil {
+			return nil, err
+		}
+		if name.Valid {
+			names = append(names, name.String)
+		}
+	}
+	return names, nil
+}
+
+func (d *DbManager) GetStatus(id, t string) (string, error) {
+	var query string
+	switch t {
+	case AppTypeDeveloper:
+		query = selectDeveloperById(
+			"'"+id+"'",
+			"status",
+		)
+	case AppTypeCompany:
+		query = selectDeveloperById(
+			"'"+id+"'",
+			"status",
+		)
+	}
+	status := sql.NullString{}
+	err := d.GetDb().QueryRow(query).Scan(&status)
+	if err != nil || !status.Valid {
+		return "", err
+	}
+
+	return status.String, nil
+}
+
 func (d *DbManager) GetApiProducts(priKey, priVal, secKey, secVal string) (apiProducts []common.ApiProduct, err error) {
 	if priKey == IdentifierAppId {
 		apiProducts, err = d.getApiProductsByAppId(priVal)
@@ -74,6 +231,67 @@
 	return
 }
 
+func (d *DbManager) GetApps(priKey, priVal, secKey, secVal string) (apps []common.App, err error) {
+	switch priKey {
+	case IdentifierAppId:
+		return d.getAppByAppId(priVal)
+	case IdentifierAppName:
+		switch secKey {
+		case IdentifierDeveloperEmail:
+			return d.getAppByAppName(priVal, secVal, "", "")
+		case IdentifierDeveloperId:
+			return d.getAppByAppName(priVal, "", secVal, "")
+		case IdentifierCompanyName:
+			return d.getAppByAppName(priVal, "", "", secVal)
+		case "":
+			return d.getAppByAppName(priVal, "", "", "")
+		}
+	case IdentifierConsumerKey:
+		return d.getAppByConsumerKey(priVal)
+	}
+	return
+}
+
+func (d *DbManager) GetCompanies(priKey, priVal, secKey, secVal string) (companies []common.Company, err error) {
+	switch priKey {
+	case IdentifierAppId:
+		return d.getCompanyByAppId(priVal)
+	case IdentifierCompanyName:
+		return d.getCompanyByName(priVal)
+	case IdentifierConsumerKey:
+		return d.getCompanyByConsumerKey(priVal)
+	}
+	return
+}
+
+func (d *DbManager) GetCompanyDevelopers(priKey, priVal, secKey, secVal string) (companyDevelopers []common.CompanyDeveloper, err error) {
+	if priKey == IdentifierCompanyName {
+		return d.getCompanyDeveloperByComName(priVal)
+	}
+	return
+}
+
+func (d *DbManager) GetAppCredentials(priKey, priVal, secKey, secVal string) (appCredentials []common.AppCredential, err error) {
+	if priKey == IdentifierConsumerKey {
+		return d.getAppCredentialByConsumerKey(priVal)
+	}
+	return
+}
+
+func (d *DbManager) GetDevelopers(priKey, priVal, secKey, secVal string) (developers []common.Developer, err error) {
+	switch priKey {
+	case IdentifierAppId:
+		return d.getDeveloperByAppId(priVal)
+	case IdentifierDeveloperEmail:
+		return d.getDeveloperByEmail(priVal)
+	case IdentifierConsumerKey:
+		return d.getDeveloperByConsumerKey(priVal)
+	case IdentifierDeveloperId:
+		return d.getDeveloperById(priVal)
+	}
+	return
+}
+
 func (d *DbManager) getApiProductsByName(apiProdName string) (apiProducts []common.ApiProduct, err error) {
 	err = d.GetDb().QueryStructs(&apiProducts,
 		sql_select_api_product+`WHERE ap.name = $1;`,
@@ -84,8 +302,8 @@
 
 func (d *DbManager) getApiProductsByAppId(appId string) (apiProducts []common.ApiProduct, err error) {
 	cols := []string{"*"}
-	query := selectApiProductsByIds(
-		selectAppCredentialMapperByAppIds(
+	query := selectApiProductsById(
+		selectAppCredentialMapperByAppId(
 			"'"+appId+"'",
 			"apiprdt_id",
 		),
@@ -98,12 +316,9 @@
 
 func (d *DbManager) getApiProductsByConsumerKey(consumerKey string) (apiProducts []common.ApiProduct, err error) {
 	cols := []string{"*"}
-	query := selectApiProductsByIds(
-		selectAppCredentialMapperByAppIds(
-			selectAppCredentialByConsumerKey(
-				"'"+consumerKey+"'",
-				"app_id",
-			),
+	query := selectApiProductsById(
+		selectAppCredentialMapperByConsumerKey(
+			"'"+consumerKey+"'",
 			"apiprdt_id",
 		),
 		cols...,
@@ -148,8 +363,8 @@
 		)
 	}
 
-	query := selectApiProductsByIds(
-		selectAppCredentialMapperByAppIds(
+	query := selectApiProductsById(
+		selectAppCredentialMapperByAppId(
 			appQuery,
 			"apiprdt_id",
 		),
@@ -160,7 +375,191 @@
 	return
 }
 
-func selectApiProductsByIds(idQuery string, colNames ...string) string {
+func (d *DbManager) getAppByAppId(id string) (apps []common.App, err error) {
+	cols := []string{"*"}
+	query := selectAppById(
+		"'"+id+"'",
+		cols...,
+	)
+	log.Debugf("getAppByAppId: %v", query)
+	err = d.GetDb().QueryStructs(&apps, query)
+	return
+}
+
+func (d *DbManager) getAppByAppName(appName, devEmail, devId, comName string) (apps []common.App, err error) {
+	cols := []string{"*"}
+	var query string
+	switch {
+	case devEmail != "":
+		query = selectAppByNameAndDeveloperId(
+			"'"+appName+"'",
+			selectDeveloperByEmail(
+				"'"+devEmail+"'",
+				"id",
+			),
+			cols...,
+		)
+	case devId != "":
+		query = selectAppByNameAndDeveloperId(
+			"'"+appName+"'",
+			"'"+devId+"'",
+			cols...,
+		)
+	case comName != "":
+		query = selectAppByNameAndCompanyId(
+			"'"+appName+"'",
+			selectCompanyByName(
+				"'"+comName+"'",
+				"id",
+			),
+			cols...,
+		)
+	default:
+		query = selectAppByName(
+			"'"+appName+"'",
+			cols...,
+		)
+	}
+	log.Debugf("getAppByAppName: %v", query)
+	err = d.GetDb().QueryStructs(&apps, query)
+	return
+}
+
+func (d *DbManager) getAppByConsumerKey(consumerKey string) (apps []common.App, err error) {
+	cols := []string{"*"}
+	query := selectAppById(
+		selectAppCredentialMapperByConsumerKey(
+			"'"+consumerKey+"'",
+			"app_id",
+		),
+		cols...,
+	)
+	log.Debugf("getAppByConsumerKey: %v", query)
+	err = d.GetDb().QueryStructs(&apps, query)
+	return
+}
+
+func (d *DbManager) getAppCredentialByConsumerKey(consumerKey string) (appCredentials []common.AppCredential, err error) {
+	cols := []string{"*"}
+	query := selectAppCredentialByConsumerKey(
+		"'"+consumerKey+"'",
+		cols...,
+	)
+	log.Debugf("getAppCredentialByConsumerKey: %v", query)
+	err = d.GetDb().QueryStructs(&appCredentials, query)
+	return
+}
+
+func (d *DbManager) getCompanyByAppId(appId string) (companies []common.Company, err error) {
+	cols := []string{"*"}
+	query := selectCompanyByComId(
+		selectAppById(
+			"'"+appId+"'",
+			"company_id",
+		),
+		cols...,
+	)
+	log.Debugf("getCompanyByAppId: %v", query)
+	err = d.GetDb().QueryStructs(&companies, query)
+	return
+}
+
+func (d *DbManager) getCompanyByName(name string) (companies []common.Company, err error) {
+	cols := []string{"*"}
+	query := selectCompanyByName(
+		"'"+name+"'",
+		cols...,
+	)
+	log.Debugf("getCompanyByName: %v", query)
+	err = d.GetDb().QueryStructs(&companies, query)
+	return
+}
+
+func (d *DbManager) getCompanyByConsumerKey(consumerKey string) (companies []common.Company, err error) {
+	cols := []string{"*"}
+	query := selectCompanyByComId(
+		selectAppById(
+			selectAppCredentialMapperByConsumerKey(
+				"'"+consumerKey+"'",
+				"app_id",
+			),
+			"company_id",
+		),
+		cols...,
+	)
+	log.Debugf("getCompanyByConsumerKey: %v", query)
+	err = d.GetDb().QueryStructs(&companies, query)
+	return
+}
+
+func (d *DbManager) getCompanyDeveloperByComName(comName string) (companyDevelopers []common.CompanyDeveloper, err error) {
+	cols := []string{"*"}
+	query := selectCompanyDeveloperByComId(
+		selectCompanyByName(
+			"'"+comName+"'",
+			"id",
+		),
+		cols...,
+	)
+	log.Debugf("getCompanyDeveloperByComName: %v", query)
+	err = d.GetDb().QueryStructs(&companyDevelopers, query)
+	return
+}
+
+func (d *DbManager) getDeveloperByAppId(appId string) (developers []common.Developer, err error) {
+	cols := []string{"*"}
+	query := selectDeveloperById(
+		selectAppById(
+			"'"+appId+"'",
+			"developer_id",
+		),
+		cols...,
+	)
+	log.Debugf("getDeveloperByAppId: %v", query)
+	err = d.GetDb().QueryStructs(&developers, query)
+	return
+}
+
+func (d *DbManager) getDeveloperByConsumerKey(consumerKey string) (developers []common.Developer, err error) {
+	cols := []string{"*"}
+	query := selectDeveloperById(
+		selectAppById(
+			selectAppCredentialMapperByConsumerKey(
+				"'"+consumerKey+"'",
+				"app_id",
+			),
+			"developer_id",
+		),
+		cols...,
+	)
+	log.Debugf("getDeveloperByConsumerKey: %v", query)
+	err = d.GetDb().QueryStructs(&developers, query)
+	return
+}
+
+func (d *DbManager) getDeveloperByEmail(email string) (developers []common.Developer, err error) {
+	cols := []string{"*"}
+	query := selectDeveloperByEmail(
+		"'"+email+"'",
+		cols...,
+	)
+	log.Debugf("getDeveloperByEmail: %v", query)
+	err = d.GetDb().QueryStructs(&developers, query)
+	return
+}
+
+func (d *DbManager) getDeveloperById(id string) (developers []common.Developer, err error) {
+	cols := []string{"*"}
+	query := selectDeveloperById(
+		"'"+id+"'",
+		cols...,
+	)
+	log.Debugf("getDeveloperById: %v", query)
+	err = d.GetDb().QueryStructs(&developers, query)
+	return
+}
+
+func selectApiProductsById(idQuery string, colNames ...string) string {
 	query := "SELECT " +
 		strings.Join(colNames, ",") +
 		" FROM kms_api_product AS ap WHERE ap.id IN (" +
@@ -170,7 +569,7 @@
 	return query
 }
 
-func selectAppCredentialMapperByAppIds(idQuery string, colNames ...string) string {
+func selectAppCredentialMapperByAppId(idQuery string, colNames ...string) string {
 	query := "SELECT " +
 		strings.Join(colNames, ",") +
 		" FROM kms_app_credential_apiproduct_mapper AS acm WHERE acm.app_id IN (" +
@@ -179,6 +578,15 @@
 	return query
 }
 
+func selectAppCredentialMapperByConsumerKey(keyQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_app_credential_apiproduct_mapper AS acm WHERE acm.appcred_id IN (" +
+		keyQuery +
+		")"
+	return query
+}
+
 func selectAppByName(nameQuery string, colNames ...string) string {
 	query := "SELECT " +
 		strings.Join(colNames, ",") +
@@ -188,6 +596,33 @@
 	return query
 }
 
+func selectAppById(appIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_app AS a WHERE a.id IN (" +
+		appIdQuery +
+		")"
+	return query
+}
+
+func selectAppByComId(comIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_app AS a WHERE a.company_id IN (" +
+		comIdQuery +
+		")"
+	return query
+}
+
+func selectAppByDevId(devIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_app AS a WHERE a.developer_id IN (" +
+		devIdQuery +
+		")"
+	return query
+}
+
 func selectAppByNameAndDeveloperId(nameQuery string, developerIdQuery string, colNames ...string) string {
 	query := selectAppByName(nameQuery, colNames...) +
 		" AND developer_id IN (" +
@@ -213,6 +648,15 @@
 	return query
 }
 
+func selectDeveloperById(idQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_developer AS dev WHERE dev.id IN (" +
+		idQuery +
+		")"
+	return query
+}
+
 func selectCompanyByName(nameQuery string, colNames ...string) string {
 	query := "SELECT " +
 		strings.Join(colNames, ",") +
@@ -222,10 +666,37 @@
 	return query
 }
 
+func selectCompanyByComId(comIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_company AS com WHERE com.id IN (" +
+		comIdQuery +
+		")"
+	return query
+}
+
+func selectCompanyDeveloperByComId(comIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_company_developer AS cd WHERE cd.company_id IN (" +
+		comIdQuery +
+		")"
+	return query
+}
+
+func selectCompanyDeveloperByDevId(devIdQuery string, colNames ...string) string {
+	query := "SELECT " +
+		strings.Join(colNames, ",") +
+		" FROM kms_company_developer AS cd WHERE cd.developer_id IN (" +
+		devIdQuery +
+		")"
+	return query
+}
+
 func selectAppCredentialByConsumerKey(consumerQuery string, colNames ...string) string {
 	query := "SELECT " +
 		strings.Join(colNames, ",") +
-		" FROM kms_app_credential AS ac WHERE ac.consumer_secret IN (" +
+		" FROM kms_app_credential AS ac WHERE ac.id IN (" +
 		consumerQuery +
 		")"
 	return query
diff --git a/accessEntity/data_test.sql b/accessEntity/data_test.sql
index 9a774df..26a877b 100644
--- a/accessEntity/data_test.sql
+++ b/accessEntity/data_test.sql
@@ -30,11 +30,11 @@
 INSERT INTO "kms_api_product" VALUES('07419482-e5a1-4fd0-9d78-3560ba522b44','515211e9','ApigeenTestApp3','ApigeenTestApp3','','{/}','AUTO','{}','{}','{prod,test}','','',NULL,'2017-09-20 22:29:11.482+00:00','haoming@apid.git','2017-09-20 22:29:11.482+00:00','haoming@apid.git','515211e9');
 INSERT INTO "kms_api_product" VALUES('db90a25a-15c8-42ad-96c1-63ed9682b5a9','515211e9','apigee-remote-proxy','apigee-remote-proxy','','{/**,/}','AUTO','{""}','{apigee-remote-proxy}','{prod,test}','','',NULL,'2017-09-20 23:05:09.234+00:00','haoming@apid.git','2017-09-20 23:05:09.234+00:00','haoming@apid.git','515211e9');
 CREATE TABLE kms_app_credential (id text,tenant_id text,consumer_secret text,app_id text,method_type text,status text,issued_at blob,expires_at blob,app_status text,scopes text,created_at blob,created_by text,updated_at blob,updated_by text,_change_selector text, primary key (id,tenant_id));
-INSERT INTO "kms_app_credential" VALUES('qUQLHViLHm9a4L623DSnmZohz6m7C83C','515211e9','abcd','408ad853-3fa0-402f-90ee-103de98d71a5','','APPROVED','2017-08-18 22:13:18.35+00:00','','','{}','2017-08-18 22:13:18.35+00:00','-NA-','2017-08-18 22:13:18.352+00:00','-NA-','515211e9');
-INSERT INTO "kms_app_credential" VALUES('00A0RcOti8kEtstbt5knxbRXFpIUGOMP','515211e9','dcba','ae053aee-f12d-4591-84ef-2e6ae0d4205d','','APPROVED','2017-09-20 23:05:59.148+00:00','','','{}','2017-09-20 23:05:59.148+00:00','-NA-','2017-09-20 23:05:59.151+00:00','-NA-','515211e9');
+INSERT INTO "kms_app_credential" VALUES('abcd','515211e9','secret1','408ad853-3fa0-402f-90ee-103de98d71a5','','APPROVED','2017-08-18 22:13:18.35+00:00','','','{}','2017-08-18 22:13:18.35+00:00','-NA-','2017-08-18 22:13:18.352+00:00','-NA-','515211e9');
+INSERT INTO "kms_app_credential" VALUES('dcba','515211e9','secret2','ae053aee-f12d-4591-84ef-2e6ae0d4205d','','APPROVED','2017-09-20 23:05:59.148+00:00','','','{}','2017-09-20 23:05:59.148+00:00','-NA-','2017-09-20 23:05:59.151+00:00','-NA-','515211e9');
 CREATE TABLE kms_app_credential_apiproduct_mapper (tenant_id text,appcred_id text,app_id text,apiprdt_id text,status text,_change_selector text, primary key (tenant_id,appcred_id,app_id,apiprdt_id));
-INSERT INTO "kms_app_credential_apiproduct_mapper" VALUES('515211e9','qUQLHViLHm9a4L623DSnmZohz6m7C83C','408ad853-3fa0-402f-90ee-103de98d71a5','b7e0970c-4677-4b05-8105-5ea59fdcf4e7','APPROVED','515211e9');
-INSERT INTO "kms_app_credential_apiproduct_mapper" VALUES('515211e9','00A0RcOti8kEtstbt5knxbRXFpIUGOMP','ae053aee-f12d-4591-84ef-2e6ae0d4205d','db90a25a-15c8-42ad-96c1-63ed9682b5a9','APPROVED','515211e9');
+INSERT INTO "kms_app_credential_apiproduct_mapper" VALUES('515211e9','abcd','408ad853-3fa0-402f-90ee-103de98d71a5','b7e0970c-4677-4b05-8105-5ea59fdcf4e7','APPROVED','515211e9');
+INSERT INTO "kms_app_credential_apiproduct_mapper" VALUES('515211e9','dcba','ae053aee-f12d-4591-84ef-2e6ae0d4205d','db90a25a-15c8-42ad-96c1-63ed9682b5a9','APPROVED','515211e9');
 CREATE TABLE kms_organization (id text,name text,display_name text,type text,tenant_id text,customer_id text,description text,created_at blob,created_by text,updated_at blob,updated_by text,_change_selector text, primary key (id,tenant_id));
 INSERT INTO "kms_organization" VALUES('e2cc4caf-40d6-4ecb-8149-ed32d04184b2','edgex01','edgex01','paid','515211e9','94cd5075-7f33-4afb-9545-a53a254277a1','','2017-08-16 22:16:06.544+00:00','foobar@google.com','2017-08-16 22:29:23.046+00:00','foobar@google.com','515211e9');
 COMMIT;
diff --git a/accessEntity/interfaces.go b/accessEntity/interfaces.go
index da5c25e..cdf4154 100644
--- a/accessEntity/interfaces.go
+++ b/accessEntity/interfaces.go
@@ -12,5 +12,18 @@
 
 type DbManagerInterface interface {
 	common.DbManagerInterface
+	GetOrgName(tenantId string) (string, error)
 	GetApiProducts(priKey, priVal, secKey, secVal string) (apiProducts []common.ApiProduct, err error)
+	GetApps(priKey, priVal, secKey, secVal string) (apps []common.App, err error)
+	GetCompanies(priKey, priVal, secKey, secVal string) (companies []common.Company, err error)
+	GetCompanyDevelopers(priKey, priVal, secKey, secVal string) (companyDevelopers []common.CompanyDeveloper, err error)
+	GetAppCredentials(priKey, priVal, secKey, secVal string) (appCredentials []common.AppCredential, err error)
+	GetDevelopers(priKey, priVal, secKey, secVal string) (developers []common.Developer, err error)
+	GetApiProductNamesByAppId(appId string) ([]string, error)
+	GetAppNamesByComId(comId string) ([]string, error)
+	GetComNamesByDevId(devId string) ([]string, error)
+	GetAppNamesByDevId(devId string) ([]string, error)
+	GetComNameByComId(comId string) (string, error)
+	GetDevEmailByDevId(devId string) (string, error)
+	GetStatus(id, t string) (string, error)
 }
diff --git a/common/data_structs.go b/common/data_structs.go
index 13dc1e9..77c0911 100644
--- a/common/data_structs.go
+++ b/common/data_structs.go
@@ -32,6 +32,7 @@
 
 type ApiProduct struct {
 	Id            string `db:"id"`
+	TenantId      string `db:"tenant_id"`
 	Name          string `db:"name"`
 	DisplayName   string `db:"display_name"`
 	Description   string `db:"description"`
@@ -47,11 +48,11 @@
 	CreatedBy     string `db:"created_by"`
 	UpdatedAt     string `db:"updated_at"`
 	UpdatedBy     string `db:"updated_by"`
-	TenantId      string `db:"tenant_id"`
 }
 
 type App struct {
 	Id          string `db:"id"`
+	TenantId    string `db:"tenant_id"`
 	Name        string `db:"name"`
 	DisplayName string `db:"display_name"`
 	AccessType  string `db:"access_type"`
@@ -67,3 +68,60 @@
 	UpdatedAt   string `db:"updated_at"`
 	UpdatedBy   string `db:"updated_by"`
 }
+
+type AppCredential struct {
+	Id             string `db:"id"`
+	TenantId       string `db:"tenant_id"`
+	ConsumerSecret string `db:"consumer_secret"`
+	AppId          string `db:"app_id"`
+	MethodType     string `db:"method_type"`
+	Status         string `db:"status"`
+	IssuedAt       string `db:"issued_at"`
+	ExpiresAt      string `db:"expires_at"`
+	AppStatus      string `db:"app_status"`
+	Scopes         string `db:"scopes"`
+	CreatedAt      string `db:"created_at"`
+	CreatedBy      string `db:"created_by"`
+	UpdatedAt      string `db:"updated_at"`
+	UpdatedBy      string `db:"updated_by"`
+}
+
+type Company struct {
+	Id          string `db:"id"`
+	TenantId    string `db:"tenant_id"`
+	Name        string `db:"name"`
+	DisplayName string `db:"display_name"`
+	Status      string `db:"status"`
+	CreatedAt   string `db:"created_at"`
+	CreatedBy   string `db:"created_by"`
+	UpdatedAt   string `db:"updated_at"`
+	UpdatedBy   string `db:"updated_by"`
+}
+
+type Developer struct {
+	Id                string `db:"id"`
+	TenantId          string `db:"tenant_id"`
+	UserName          string `db:"username"`
+	FirstName         string `db:"first_name"`
+	LastName          string `db:"last_name"`
+	Password          string `db:"password"`
+	Email             string `db:"email"`
+	Status            string `db:"status"`
+	EncryptedPassword string `db:"encrypted_password"`
+	Salt              string `db:"salt"`
+	CreatedAt         string `db:"created_at"`
+	CreatedBy         string `db:"created_by"`
+	UpdatedAt         string `db:"updated_at"`
+	UpdatedBy         string `db:"updated_by"`
+}
+
+type CompanyDeveloper struct {
+	TenantId    string `db:"tenant_id"`
+	CompanyId   string `db:"company_id"`
+	DeveloperId string `db:"developer_id"`
+	Roles       string `db:"roles"`
+	CreatedAt   string `db:"created_at"`
+	CreatedBy   string `db:"created_by"`
+	UpdatedAt   string `db:"updated_at"`
+	UpdatedBy   string `db:"updated_by"`
+}