0

I am attempting to parse MatterMark's API, but I am planning to do so selectively, picking only the value pairs that are relevant. The example JSON response is available to be viewed in MatterMark's documentation (here).

Here's my Wrapper:

public class MMarkWrapper {
    public class mmark_company_profile {
        public string name {get;set;}
        public string description {get;set;}
        public string employees {get;set;}
        public string employees_6_months_ago {get;set;}
        public string last_funding_amount {get;set;}
        public string last_funding_date {get;set;}
        public string country {get;set;}
        public string total_funding {get;set;}
        public string acquired_by {get;set;}
        public List<mmark_funding_round> mmark_funding_rounds {get;set;}

    }
    public class mmark_funding_round {
        public string amount {get;set;}
        public string transaction_currency {get;set;}
        public string series {get;set;}
        public string funding_date {get;set;}
        public string investors {get;set;}

    }

    public List<mmark_company_profile> mmark_company_profile_list {get; set;}

}

And the Parser:

public class MMarkParser {
    public MMarkWrapper wrapper {
        get;
        set;
    }

    public void parse() {

        //request class
        HTTPRequest request = new HTTPRequest();
        request.setEndpoint(Label.MatterMarkAPI+'/domains/'+ 'company.com' +'/companies?key=' +'API_KEY');  
        request.setMethod('GET');

        //response class
        HTTP h = new HTTP();
        HTTPResponse response = h.send(request); 


        wrapper = (MMarkWrapper) JSON.deserialize(response.getBody(), MMarkWrapper.class);
        System.debug(wrapper);

    }
}

I am trying to get it displayed on this page, but all I am getting is a blank page...

<apex:page controller="MMarkParser">
    <apex:form >
        <apex:pageBlock title="MMarkParserResponse">
            <apex:pageBlockButtons >
                <apex:commandButton value="submit" action="{!parse}" reRender="mmark_company_profile"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection id="mmark_company_profile" columns="1">
                <apex:repeat value="{!wrapper.mmark_company_profile_list}" var="mmark_company_profile">
                    <apex:pageBlockSection columns="2">
                        <apex:facet name="header">Company {!mmark_company_profile.name}</apex:facet>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Description" for="description" />
                            <apex:outputText value="{!mmark_company_profile.description}" id="description" />
                        </apex:pageBlockSectionItem>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Employees" for="employees" />
                            <apex:outputText value="{!mmark_company_profile.employees}" id="employees" />
                        </apex:pageBlockSectionItem>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection columns="1">
                        <apex:facet name="header">Funding {!mmark_company_profile.name} Series</apex:facet>
                        <apex:pageBlockTable value="{!mmark_company_profile.mmark_funding_rounds}" var="item" id="mmark_funding_rounds">
                            <apex:column value="{!item.amount}" headerValue="Amount" />
                            <apex:column value="{!item.transaction_currency}" headerValue="Transaction Currency" />
                            <apex:column value="{!item.series}" headerValue="Series" />
                            <apex:column value="{!item.funding_date}" headerValue="Funding Date" />
                        </apex:pageBlockTable>
                    </apex:pageBlockSection>
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock> 
    </apex:form>
</apex:page>

I've been trying to debug it with no success, any ideas why this may be not working?

3
  • 1
    FYI you can select a code block and hit CTRL + K (or ⌘ + K on a mac) to format it.
    – Adrian Larson
    Jun 1 '17 at 21:19
  • you just declared the mmark_company_profile_list list and you are putting nothing into the list !!!!
    – Rao
    Jun 1 '17 at 23:12
  • This is a technique I saw across many blogs and tutorials. My understanding is that this list would include mmark_company_profile data. Jun 1 '17 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.