Skip to content

Commit fb8a9ce

Browse files
author
Anirudh S
committed
Instructions for showing KB articles belonging to a section, in HappyFox
1 parent 418bc8f commit fb8a9ce

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ Installating the HelpStack library is fairly straight-forward.
7575
exclude group: 'org.apache.httpcomponents', module: 'httpmime'
7676
}
7777

78-
### External Dependencies
79-
80-
HelpStack depends on the following libraries:
81-
82-
com.android.support:appcompat-v7:20.0.0
83-
com.google.code.gson:gson:2.2.4
84-
org.apache.httpcomponents:httpmime:4.2.6
85-
com.mcxiaoke.volley:library-aar:1.+
86-
87-
8878
## Using the Library
8979

9080
Broadly speaking, there are just 3 steps to begin using HelpStack within your app:
@@ -108,7 +98,6 @@ Create a custom *Application* class which extends the **Application** class. Be
10898
Obtain the necessary credentials for the gear of your choice and create a suitable Gear object. Set the Gear object with *HSHelpStack* instance only once.
10999

110100
##### i. HappyFox:
111-
Credentials: *HappyFox Account URL*, *API Key*, *Auth Code*, *Category ID* and *Priority ID*.
112101

113102
public class HSApplication extends Application {
114103
@@ -129,6 +118,9 @@ Credentials: *HappyFox Account URL*, *API Key*, *Auth Code*, *Category ID* and *
129118
"<Category ID>",
130119
"<Priority ID>");
131120
121+
// [Optional] Set the Section Id of your Knowledge Base articles
122+
happyfoxGear.setSectionId("<Section id>");
123+
132124
// Set the Gear
133125
helpStack.setGear(happyfoxGear);
134126
}
@@ -137,16 +129,16 @@ Credentials: *HappyFox Account URL*, *API Key*, *Auth Code*, *Category ID* and *
137129

138130
The API key and Auth code can be found in your HappyFox account under *Manage* > *Integrations*. You can generate an API key and Auth code by clicking on the API configure link.
139131

140-
HappyFox requires that the Priority ID and Category ID cannot be nil. This is the ID of the priority and the category with which tickets will be created when a customer reports an issue.
132+
Priority ID and Category ID cannot be nil. These are the ID's of the priority and the category with which tickets will be created. Setting the Section ID of your KB articles is optional.
141133

142134
*Example*:
143135

144136
https://example.happyfox.com/api/1.1/json/priorities/
145137
https://example.happyfox.com/api/1.1/json/categories/
138+
https://example.happyfox.com/api/1.1/json/kb/sections/
146139

147140

148141
##### ii. Zendesk:
149-
Credentials: *Zendesk Account URL*, *Staff Email address* and *API token*.
150142

151143
public class HSApplication extends Application {
152144
@@ -174,7 +166,6 @@ Credentials: *Zendesk Account URL*, *Staff Email address* and *API token*.
174166
The token can be found in your Zendesk account under Settings > Channels > API.
175167

176168
##### iii. Desk:
177-
**Credentials**: *Desk Account URL*, *To Help Email address*, *Staff Email address* and *Staff password*
178169

179170
public class HSApplication extends Application {
180171
@@ -277,6 +268,15 @@ Override the styles specified in **/values/hs_custom_theme.xml**
277268

278269
If you want the complete look-and-feel of a theme, you might also want to update the color of your app's Action bar.
279270

271+
272+
## External Dependencies
273+
274+
HelpStack depends on the following libraries:
275+
276+
com.android.support:appcompat-v7:20.0.0
277+
com.google.code.gson:gson:2.2.4
278+
org.apache.httpcomponents:httpmime:4.2.6
279+
com.mcxiaoke.volley:library-aar:1.+
280280

281281
## About
282282
For more information about HelpStack, visit [helpstack.io](http://www.helpstack.io).

helpstack/src/com/tenmiles/helpstack/gears/HSHappyfoxGear.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public class HSHappyfoxGear extends HSGear {
8181
private String auth_code;
8282
private String priority_id;
8383
private String category_id;
84-
85-
public String hf_section_id;
84+
private String section_id;
8685

8786
// This are cached here so server call can be minimized and improve the speed of UI
8887
JSONArray allSectionsArray;
@@ -113,7 +112,7 @@ public void fetchKBArticle(String cancelTag, HSKBItem section, RequestQueue queu
113112
if (section == null) {
114113
// This is first request of sections
115114

116-
if (this.hf_section_id == null) {
115+
if (this.section_id == null) {
117116
// Fetch all sections
118117
String url = getApiUrl().concat("kb/sections/");
119118

@@ -136,7 +135,7 @@ public void onResponse(JSONArray sectionsArray) {
136135
}
137136
else {
138137
// Fetch individual section
139-
String url = getApiUrl().concat("kb/section/").concat(this.hf_section_id).concat("/");
138+
String url = getApiUrl().concat("kb/section/").concat(this.section_id).concat("/");
140139

141140
JsonObjectRequest request = new JsonObjectRequest(url, null, new HappyfoxArrayBaseListener<JSONObject>(success, errorListener) {
142141

@@ -342,6 +341,10 @@ public void onResponse(JSONObject response) {
342341

343342
}
344343

344+
public void setSectionId(String sectionId) {
345+
this.section_id = sectionId;
346+
}
347+
345348
private HSKBItem[] getArticlesFromSection(JSONObject sectionObject) throws JSONException {
346349
JSONArray articleArray = sectionObject.getJSONArray("articles");
347350
ArrayList<HSKBItem> kbArticleArray = new ArrayList<HSKBItem>();

0 commit comments

Comments
 (0)